The X event type is mapped into the string name of the event, preceded by "X_". For instance, an X ButtonPress event becomes "X_ButtonPress". Note that the case of the string is preserved, and significant in all comparisons.
For ButtonPress and ButtonRelease events, the button, x, and y instance variables of the generated event object are set. For KeyPress and KeyRelease events, the key, x, and y instance variables of the generated event object are set. For MotionNotify, EnterNotify, and LeaveNotify events, the x and y instance variables of the generated event object are set.
-- pressing button 1, dragging the mouse, then releasing button 1 causes an -- area select message to be displayed -- clicking button 1 causes an object select message to be displayed -- clicking button 2 causes a button called "Hi" to be displayed -- clicking button 3 causes a button called "Quit" to be displayed
<xinit
ui Application="Event test" create! ;
ui_row_column new: wkspc parent=ui @ "height" : 300 @ "width" : 300 input_mask=( ButtonPressMask, ButtonReleaseMask, ButtonMotionMask ) create! ;
ui on! ;
ui_button new: button3 parent=wkspc label= "Quit" action= quit_action create! off! ;
ui_button new: button2 parent=wkspc label= "Hi" action= hi_action create! off! ;
xdisplay sync!;
string new: str;
actions new: object_action tick_actions=` str = `Object selected' print:value; ' ;
actions new: area_action tick_actions=` str = `Area selected' print:value; ' ;
event new: press type=`X_ButtonPress' window=[wkspc window_id?] button=1 ;
event new: release type=`X_ButtonRelease' window=[wkspc window_id?] button=1 ;
event new: motion type=`X_MotionNotify' window=[wkspc window_id?] button=1 ;
event new: menupress type=`X_ButtonPress' window=[wkspc window_id?] button=3 ;
event new: middlepress type=`X_ButtonPress' window=[wkspc window_id?] button=2 ;
actions new: quit_action tick_actions=` str = `BYE!' print:value; ui exit!; ' ;
actions new: hi_action tick_actions=` str = `HI!' print:value; ' ;
actions new: popquit tick_actions=` str = "Quit button enabled" print:value; button3 on!; ' ;
actions new: pophi tick_actions=` str = "Hi button enabled" print:value; button2 on!; ' ;
xeventcontroller new: xev -- we don't care about unspecified events ignore_unknown_events!
-- define state machine and its transitions -- current state -- event -- next state -- transition action transition:(start, menupress, start, `popquit') transition:(start, middlepress, start, `pophi') transition:(start, press, buttondown, `') transition:(buttondown, motion, buttondownmoved, `') transition:(buttondown, release, start, object_action) transition:(buttondownmoved, release, start, area_action) transition:(buttondownmoved, motion, buttondownmoved, `') -- define the start state state=start -- start accepting events start! ;
ui event= `xev' start! ;
Please send comments and suggestions to
its-documentation@rpi.edu