Created
October 3, 2011 20:21
-
-
Save stuartpb/1260133 to your computer and use it in GitHub Desktop.
grab, drag, and release handler framework for IUPLua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| do | |
| local dox, doy | |
| local function drag(x, y) | |
| end | |
| local function grab(x, y) | |
| dox, doy = x, y | |
| drag(x, y) | |
| end | |
| local function release(x, y) | |
| dox, doy = nil, nil | |
| end | |
| function cnv:button_cb(but, pressed, x, y, status) | |
| if but == iup.BUTTON1 then | |
| if pressed == 1 then | |
| grab(x, y) | |
| elseif dox then | |
| release(x, y) | |
| end | |
| end | |
| end | |
| function cnv:motion_cb(x, y, status) | |
| if dox then | |
| if iup.isbutton1(status) then | |
| drag(x, y) | |
| else --mouse has been released without triggering button_cb | |
| release(x, y) | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment