factor/library/ui/gestures.factor

39 lines
1.1 KiB
Factor
Raw Normal View History

2005-01-31 22:32:06 -05:00
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: gadgets
USING: alien generic hashtables kernel lists math matrices sdl
sequences ;
2005-02-05 11:52:24 -05:00
: action ( gadget gesture -- quot )
2005-07-13 21:17:47 -04:00
swap gadget-gestures ?hash ;
2005-02-05 11:52:24 -05:00
: set-action ( gadget quot gesture -- )
2005-07-13 21:17:47 -04:00
pick gadget-gestures ?set-hash swap set-gadget-gestures ;
2005-02-01 21:47:10 -05:00
2005-03-01 22:11:08 -05:00
: add-actions ( alist gadget -- )
swap [ unswons set-action ] each-with ;
2005-02-01 21:47:10 -05:00
: handle-gesture* ( gesture gadget -- ? )
2005-07-13 21:17:47 -04:00
tuck gadget-gestures ?hash dup [ call f ] [ 2drop t ] ifte ;
2005-01-31 22:32:06 -05:00
2005-02-12 21:15:30 -05:00
: handle-gesture ( gesture gadget -- ? )
2005-01-31 22:32:06 -05:00
#! If a gadget's handle-gesture* generic returns t, the
#! event was not consumed and is passed on to the gadget's
2005-02-12 21:15:30 -05:00
#! parent. This word returns t if no gadget handled the
#! gesture, otherwise returns f.
[ dupd handle-gesture* ] each-parent nip ;
: user-input ( ch gadget -- ? )
[ dupd user-input* ] each-parent nip ;
2005-02-01 20:14:03 -05:00
2005-02-01 21:47:10 -05:00
! Mouse gestures are lists where the first element is one of:
SYMBOL: motion
2005-02-26 02:11:25 -05:00
SYMBOL: drag
2005-02-01 21:47:10 -05:00
SYMBOL: button-up
SYMBOL: button-down
SYMBOL: mouse-enter
SYMBOL: mouse-leave
2005-02-05 11:52:24 -05:00
SYMBOL: lose-focus
SYMBOL: gain-focus