factor/library/ui/events.factor

37 lines
1.1 KiB
Factor
Raw Normal View History

2005-02-01 22:00:55 -05:00
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: gadgets
USING: alien generic kernel lists math namespaces sdl sdl-event
sdl-video ;
GENERIC: handle-event ( event -- )
M: alien handle-event ( event -- )
drop ;
M: quit-event handle-event ( event -- )
drop f world get set-world-running? ;
M: resize-event handle-event ( event -- )
dup resize-event-w swap resize-event-h
[ world get resize-gadget ] 2keep
0 SDL_HWSURFACE SDL_RESIZABLE bitor init-screen
world get redraw ;
2005-02-05 11:52:24 -05:00
: button-gesture ( button gesture -- [ gesture button ] )
swap unit append my-hand hand-clicked handle-gesture ;
2005-02-01 22:00:55 -05:00
M: button-down-event handle-event ( event -- )
button-event-button dup my-hand button/
2005-02-05 11:52:24 -05:00
[ button-down ] button-gesture ;
2005-02-01 22:00:55 -05:00
M: button-up-event handle-event ( event -- )
2005-02-05 11:52:24 -05:00
button-event-button dup my-hand button\
[ button-up ] button-gesture ;
: motion-event-pos ( event -- x y )
dup motion-event-x swap motion-event-y ;
2005-02-01 22:00:55 -05:00
M: motion-event handle-event ( event -- )
2005-02-05 11:52:24 -05:00
motion-event-pos my-hand move-hand ;