factor/library/ui/events.factor

48 lines
1.3 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 sequences ;
2005-02-01 22:00:55 -05:00
GENERIC: handle-event ( event -- )
2005-04-30 14:27:40 -04:00
M: object handle-event ( event -- )
2005-02-01 22:00:55 -05:00
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
2005-02-19 17:54:04 -05:00
world get relayout ;
2005-02-01 22:00:55 -05:00
2005-02-05 11:52:24 -05:00
: button-gesture ( button gesture -- [ gesture button ] )
2005-03-03 20:43:55 -05:00
swap unit append hand hand-clicked handle-gesture drop ;
2005-02-01 22:00:55 -05:00
M: button-down-event handle-event ( event -- )
2005-03-03 20:43:55 -05:00
button-event-button dup 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-03-03 20:43:55 -05:00
button-event-button dup hand button\
2005-02-05 11:52:24 -05:00
[ 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-03-03 20:43:55 -05:00
motion-event-pos hand move-hand ;
2005-02-07 10:24:03 -05:00
M: key-down-event handle-event ( event -- )
2005-02-12 21:15:30 -05:00
dup keyboard-event>binding
2005-03-03 20:43:55 -05:00
hand hand-focus handle-gesture [
2005-02-12 21:15:30 -05:00
keyboard-event-unicode dup 0 = [
drop
] [
2005-03-03 20:43:55 -05:00
hand hand-focus user-input drop
2005-02-12 21:15:30 -05:00
] ifte
] [
drop
] ifte ;