Mouse gestures
Factor handbook » UI framework » Implementing new gadgets » UI gestures

Prev:Free-form keyboard input
Next:Multi-touch gestures


There are two types of mouse gestures indicating button clicks:
button-down

button-up


When a mouse button is pressed or released, two gestures are sent. The first gesture indicates the specific button number, and if this gesture is not handled, the second has a button number set to f:
T{ button-down f 1 } T{ button-down f f }

Because tuple literals fill unspecified slots with f, the last gesture can be written as T{ button-down }.

Gestures to indicate mouse motion, depending on whenever a button is held down or not:
motion

drag


Gestures to indicate that the mouse has crossed gadget boundaries:
mouse-enter

mouse-leave


A number of global variables are set after a mouse gesture is sent. These variables can be read to obtain additional information about the gesture.
hand-gadget

hand-world

hand-loc

hand-buttons

hand-clicked

hand-click-loc

hand-click#


There are some utility words for working with click locations:
hand-rel ( gadget -- loc )

hand-click-rel ( gadget -- loc )

drag-loc ( -- loc )


Mouse scroll wheel gesture:
mouse-scroll


Global variable set when a mouse scroll wheel gesture is sent:
scroll-direction