Revise keys.
This commit is contained in:
@ -27,13 +27,12 @@
|
||||
\ mouse-x ( -- n )
|
||||
\ mouse-y ( -- n )
|
||||
\ last-key ( -- n )
|
||||
\ last-keysym ( -- n )
|
||||
\ last-keycode ( -- n )
|
||||
\ last-char ( -- n )
|
||||
\ pressed? ( k -- f )
|
||||
\ event ( -- n )
|
||||
\ Event constants:
|
||||
\ UNKNOWN TIMEOUT RESIZED EXPOSED
|
||||
\ MOTION PRESSED RELEASED FINISHED
|
||||
\ UNKNOWN TIMEOUT RESIZED EXPOSED MOTION
|
||||
\ PRESSED RELEASED TYPED FINISHED
|
||||
\ Key/Button constants:
|
||||
\ LEFT-BUTTON MIDDLE-BUTTON RIGHT-BUTTON
|
||||
|
||||
@ -47,7 +46,8 @@ vocabulary internals
|
||||
4 constant MOTION
|
||||
5 constant PRESSED
|
||||
6 constant RELEASED
|
||||
7 constant FINISHED
|
||||
7 constant TYPED
|
||||
8 constant FINISHED
|
||||
|
||||
255 constant LEFT-BUTTON
|
||||
254 constant MIDDLE-BUTTON
|
||||
@ -56,8 +56,7 @@ vocabulary internals
|
||||
0 value mouse-x
|
||||
0 value mouse-y
|
||||
0 value last-key
|
||||
0 value last-keysym
|
||||
0 value last-keycode
|
||||
0 value last-char
|
||||
0 value event
|
||||
0 value width
|
||||
0 value height
|
||||
|
||||
@ -18,8 +18,16 @@ grf
|
||||
: run
|
||||
begin
|
||||
wait
|
||||
0 to color
|
||||
0 0 width height box
|
||||
PRESSED event = if
|
||||
." DOWN: " last-key . cr
|
||||
then
|
||||
RELEASED event = if
|
||||
." UP: " last-key . cr
|
||||
then
|
||||
TYPED event = if
|
||||
." CHAR: " last-char . cr
|
||||
then
|
||||
0 to color 0 0 width height box
|
||||
LEFT-BUTTON pressed? if $ccccff else $ffccff then to color
|
||||
mouse-x mouse-y height heart
|
||||
flip
|
||||
|
||||
@ -85,19 +85,27 @@ cell allocate throw to backbuffer
|
||||
0 exit
|
||||
then
|
||||
WM_KEYDOWN msg = if
|
||||
w 0 max 255 min to last-key
|
||||
1 last-key key-state!
|
||||
PRESSED to event
|
||||
then
|
||||
WM_KEYUP msg = if
|
||||
w 0 max 255 min to last-key
|
||||
0 last-key key-state!
|
||||
RELEASED to event
|
||||
then
|
||||
WM_CHAR msg = if
|
||||
w to last-char
|
||||
TYPED to event
|
||||
0 exit
|
||||
then
|
||||
msg msg>button if
|
||||
l GET_X_LPARAM to mouse-x
|
||||
l GET_Y_LPARAM to mouse-y
|
||||
msg msg>pressed msg msg>button key-state!
|
||||
msg msg>button to last-keycode
|
||||
msg msg>pressed if PRESSED else RELEASED then to event
|
||||
msg msg>button to last-key
|
||||
msg msg>pressed dup last-key key-state!
|
||||
if PRESSED else RELEASED then to event
|
||||
0 exit
|
||||
then
|
||||
WM_MOUSEMOVE msg = if
|
||||
l GET_X_LPARAM to mouse-x
|
||||
|
||||
Reference in New Issue
Block a user