411 REFERENCE · Wikibooks
BlitzMax/Modules/Events/Events
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Event objects are used to notify your application about external events such as user input,
user interface activity and so on.
The are two main ways your program can receive events: either by adding a hook function to
the EmitEventHook hook, or by using using the global event queue
The most important field in an event object is the id field, which identifies the kind of
event:
Event id Description EVENT_APPSUSPEND Application suspended EVENT_APPRESUME Application resumed EVENT_APPTERMINATE Application wants to terminate EVENT_KEYDOWN Key pressed. Event data contains keycode EVENT_KEYUP Key released. Event data contains keycode EVENT_KEYCHAR Key character. Event data contains unicode value EVENT_MOUSEDOWN Mouse button pressed. Event data contains mouse button code EVENT_MOUSEUP Mouse button released. Event data contains mouse button code EVENT_MOUSEMOVE Mouse moved. Event x and y contain mouse coordinates EVENT_MOUSEWHEEL Mouse wheel spun. Event data contains delta clicks EVENT_MOUSEENTER Mouse entered gadget area EVENT_MOUSELEAVE Mouse left gadget area EVENT_TIMERTICK Timer ticked. Event source contains timer object EVENT_HOTKEYHIT Hot key hit. Event data and mods contains hotkey keycode and modifier EVENT_MENUACTION Menu has been selected EVENT_WINDOWMOVE Window has been moved EVENT_WINDOWSIZE Window has been resized EVENT_WINDOWCLOSE Window close icon clicked EVENT_WINDOWACTIVATE Window activated EVENT_WINDOWACCEPT Drag and Drop operation was attempted EVENT_GADGETACTION Gadget state has been updated EVENT_GADGETPAINT A Canvas Gadget needs to be redrawn EVENT_GADGETSELECT A TreeView Node has been selected EVENT_GADGETMENU User has right clicked a TreeView Node or TextArea gadget EVENT_GADGETOPEN A TreeView Node has been expanded EVENT_GADGETCLOSE A TreeView Node has been collapsed EVENT_GADGETDONE An HTMLView has completed loading a page
Globals
EmitEventHook
Global EmitEventHook=AllocHookId()
Description: Hook id for emitted events
Information:
The EmitEventHook global variable contains a hook id for use with AddHook.
Each time EmitEvent is called, the event is passed to all EmitEventHook
hook functions by means of the hook function data parameter.
Types
TEvent
Event object type
Fields
id
source
data
mods
x
y
extra
Methods
Emit
ToString
Functions
Create
AllocUserId
TEvent: Fields
id
Field id
Description: Event identifier
source
Field source:Object
Description: Event source object
data
Field data
Description: Event specific data
mods
Field mods
Description: Event specific modifiers
x
Field x
Description: Event specific position data
y
Field y
Description: Event specific position data
extra
Field extra:Object
Description: Event specific extra information
TEvent: Methods
Emit
Method Emit()
Description: Emit this event
Information:
This method runs all EmitEventHook hook function, passing Self as
the hook data.
ToString
Method ToString$()
Description: Convert event to a string
Information:
This method is mainly useful for debugging purposes.
TEvent: Functions
Create
Function Create:TEvent( id,source:Object=Null,data=0,mods=0,x=0,y=0,extra:Object=Null )
Description: Create an event object
Returns: A new event object
AllocUserId
Function AllocUserId()
Description: Allocate a user event id
Returns: A new user event id
Functions
EmitEvent
Function EmitEvent( event:TEvent )
Description: Emit an event
Information:
Runs all EmitEventHook hooks, passing event as the hook data.
CreateEvent
Function CreateEvent:TEvent( id,source:Object=Null,data=0,mods=0,x=0,y=0,extra:Object=Null )
Description: Create an event object
Returns: A new event object
AllocUserEventId
Function AllocUserEventId( description$="" )
Description: Allocate a user event id
Returns: A new user event id