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
|
2005-09-11 20:46:55 -04:00
|
|
|
USING: arrays alien gadgets-layouts generic kernel lists math
|
2005-10-07 20:26:21 -04:00
|
|
|
namespaces sdl sequences strings ;
|
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 ;
|
|
|
|
|
2005-05-03 23:50:04 -04:00
|
|
|
: button-gesture ( button gesture -- )
|
2005-10-07 20:26:21 -04:00
|
|
|
swap add hand get hand-clicked handle-gesture drop ;
|
2005-02-01 22:00:55 -05:00
|
|
|
|
|
|
|
M: button-down-event handle-event ( event -- )
|
2005-10-07 20:26:21 -04:00
|
|
|
button-event-button dup hand get 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-10-07 20:26:21 -04:00
|
|
|
button-event-button dup hand get button\
|
2005-02-05 11:52:24 -05:00
|
|
|
[ button-up ] button-gesture ;
|
|
|
|
|
2005-07-12 20:30:05 -04:00
|
|
|
: motion-event-loc ( event -- loc )
|
2005-09-11 20:46:55 -04:00
|
|
|
dup motion-event-x swap motion-event-y 0 3array ;
|
2005-02-01 22:00:55 -05:00
|
|
|
|
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-10-07 20:26:21 -04:00
|
|
|
hand get hand-focus handle-gesture [
|
|
|
|
keyboard-event-unicode dup control? [
|
2005-02-12 21:15:30 -05:00
|
|
|
drop
|
|
|
|
] [
|
2005-10-07 20:26:21 -04:00
|
|
|
hand get hand-focus user-input drop
|
2005-09-24 15:21:17 -04:00
|
|
|
] if
|
2005-02-12 21:15:30 -05:00
|
|
|
] [
|
|
|
|
drop
|
2005-09-24 15:21:17 -04:00
|
|
|
] if ;
|