factor/library/ui/events.factor

49 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: arrays alien gadgets-layouts 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
[ 0 3array world get set-gadget-dim ] 2keep
2005-02-01 22:00:55 -05:00
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
: button-gesture ( button gesture -- )
swap add 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-loc ( event -- loc )
dup motion-event-x swap motion-event-y 0 3array ;
2005-02-01 22:00:55 -05:00
M: motion-event handle-event ( event -- )
motion-event-loc 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 ;