WaitEvent( [timeout] )

Parameters

timeout - How long waitevent should wait, in milliseconds.

Description

WaitEvent waits for an event and returns its id.

If no event occurs within the specified timeout, WaitEvent returns 0.

If the timeout parameter is omitted, WaitEvent waits indefinitely.

Event identifiers:

$101 - Key down
Generated when the user presses a key. EventData contains the 'raw scancode' of the key.

$102 - Key up
Generated when the user releases a key. EventData contains the 'raw scancode' of the key.

$103 - Key stroke
Generated when the user presses a key or when a keystroke is automatically generated due to keyboard repeat. EventData contains the ascii code of the key.

$201 - Mouse down
Generated when the user presses a mouse button while the mouse is positioned over a non-interactive gadget (such as a canvas, window, panel or label, but not a button). EventData contains the button being pressed: 1 for the left button, 2 for the right button or 3 for the middle button. EventSource contains the gadget handle. Note that you will only get a gadget action event ($401) for buttons, not a mouse down and a mouse up.

$202 - Mouse up
Generated when the user releases a mouse button while the mouse is positioned over a non-interactive gadget (such as a canvas, window, panel or label, but not a button). EventData contains the button be release: 1 for the left button, 2 for the right button or 3 for the middle button. EventSource contains the gadget handle.

$203 - Mouse move
Generated when the user moves the mouse while it is positioned over a canvas gadget. EventX and EventY contain the new mouse coordinates, and EventSource contains the canvas gadget handle.

$204 - Mouse wheel
Generated when the user spins the mouse wheel. EventData contains the number of 'clicks' the wheel has
been spun. This event is generated irrespective of the mouse being over a gadget or not. As such EventSource contains the currently active window handle.

$205 - Mouse enter
Generated when the mouse pointer enters a canvas gadget.

$206 - Mouse leave
Generated when the mouse pointer leaves a canvas gadget.

$401 - Gadget action
Generated when the user changes the state of a gadget. This can include such actions as pressing a button, or typing into a textfield. EventSource contains the handle of the gadget that caused the event.

$801 - Window move
Generated when the user moves a window. EventSource contains the handle of the window gadget that has moved, and EventX and EventY contain the new location of the window.

$802 - Window size
Generated when the user sizes a window. EventSource contains the handle of the window gadget that has sized, and EventX and EventY contain the new size of the window.

$803 - Window close
Generated when the user clicks a window's 'close' box. It is up to the program to actually close the window (see FreeGadget).

$804 - Window activate
Generated when the user activates a window. EventSource contains the handle of the window gadget that was activated.

$1001 - Menu event
Generated when the user selects a menu. EventData contains the integer identifier of the menu selected.

$2001 - App suspend
Generated when the user switches to another application.

$2002 - App resume
Generated when the user switches back to your application.

$2003 - App Display Change
Generated when the display mode changes.

$2004 - App Begin Modal
Generated when the application goes into a modal event loop. This is typically caused by resizing a window
or dragging a slider. You shouldn't generally have to worry about modal event loops.

$2005 - App End Modal
Generated when the application ends a modal event loop.

$4001 - Timer tick
Generated when a custom timer ticks over (see Timers). EventSource contains the handle of the timer, and EventData contains the total number of timer ticks that have occurred.

See also: EventID, EventSource, EventData, EventX, EventY, PeekEvent, FlushEvent.

Example

; Example originally provided by Mag, tidied up by Mark Tiffany

; create a window...
WinHandle=CreateWindow("WaitEvent Example",0,0,400,200)
; ...and a single button upon that window
ExitButton=CreateButton("Exit",50,50,300,40,WinHandle)

; main loop to handle events
Repeat
If WaitEvent()=$401 Then
If EventSource()=ExitButton Then Exit
End If
Forever
End

Index

Click here to view the latest version of this page online