Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

28
LINES

< > BotCompany Repo | #106 // GUI mouse event test

Rendition of first frame

Lua code - GUI

1  
width=100
2  
height=50
3  
--print("pixels:", pixels)
4  
repaint=not notFirstTime
5  
notFirstTime=true
6  
pixels=nil -- optimization (no redraw effort if image not changed)
7  
8  
if inputEvents then
9  
  for _, e in ipairs(inputEvents) do
10  
    --print(e[1])
11  
    if e[1] == 'mousePressed' then
12  
      mouse = true
13  
      repaint = true
14  
    elseif e[1] == 'mouseReleased' then
15  
      mouse = false
16  
      repaint = true
17  
    end
18  
  end
19  
end
20  
21  
if repaint then
22  
  pixels = {}
23  
  if mouse then
24  
    for i=1, width*height do pixels[i] = -1 end
25  
  end
26  
end
27  
28  
animateAgainIn = 100

Author comment

It works! :)

Now with optimization to avoid idle redraws.

show applet  test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Image recognition results

Recognizer Recognition Result Visualize Recalc
#308 560 [visualize]

Snippet ID: #106
Snippet name: GUI mouse event test
Eternal ID of this version: #106/1
Text MD5: a3745a5ff9c9ceb49e46804315465c95
Author: stefan
Category: gui tests
Type: Lua code - GUI
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2014-01-09 03:06:07
Source code size: 560 bytes / 28 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1550 / 341
Referenced in: [show references]