The event on.grabDown is used to handle grabbing motions (cursor press & hold).
This routine is called in these situations:
- When the user presses and holds the Select key on a device
- When the user presses Ctrl + Select on a device
- When the user presses the middle mouse button over an active card on the desktop
They will be preceded by a on.mouseDown event when generated by pressing and holding the Select key on a device.
Below is an example of a program that handles the grabbing motion to move an object :
function Ball:move(x,y) self.x = x self.y = y platform.window:invalidate() end function on.grabDown(x,y) isGrabbing = not isGrabbing -- makes the variable switch from true to false and vice versa platform.window:invalidate() end function on.mouseMove(x,y) if isGrabbing and (trackedBall and trackedBall.isActive) then -- assuming trackedBall is defined etc. trackedBall:move(x-trackedBall.r/2,y-trackedBall.r/2) end end
You can see the whole lua example about Ball generation and movements here : Balls Example (Class + Events Handling)