GIR Events {gir}R Documentation

GIR Event Handling

Description

These functions allow R code to receive and respond to UI events.

Usage

girProcessEvents()
girSetHandler(event.id, handler.func, window.index = 0)
girRemoveHandler(event.id, window.index = 0)
girClearEvents(window.index = 0)
girTime()

handlerFunction(window.index, event.id, arg1, arg2, time)

Arguments

window.index vector of integers; containing the indices (or index) of windows on which to operate. An index of 0 specifies the current window. For the handler function, the index of the window that received the event.
event.id vector of integers; specifying the events(s) to set or remove handlers for; should consist of value(s) from the table below. For the handler function, an integer specifying what event caused the function to be called.
handler.func the function to assign to handle the specified event for the specified window(s). One function may be assigned to handle many events. The function must have arguments as specified above. They are not named, so be sure their order is correct.
arg1, arg2 General-purpose arguments to the handler function. Described below.
time The time the event was received, in milliseconds from some arbitrary origin. See girTime.

Details

GIR has a simple event system that allows your code to receive and respond to events generated by the user or the windowing system.

Each window maintains an event queue. If a window is set to receive events, they will be added (asynchronously) to the queue by GIR.

To instruct a window to receive events, create it with a doevents argument of TRUE, or call girSetDoEvents with a doevents argument of TRUE. girSetDoEvents may be called at any time with a doevents argument of FALSE to instruct the window to ignore subsequent events.

girSetHandler and girRemoveHandler assign and remove the handler function for specified event(s) on specified window(s). handler.id specifies which event(s) the function should handle, and should be a value from the Events table below.

Value

girSetHandler and girRemoveHandler return the handler function(s) which were replaced or removed (or NULL if there wasn't one for the corresponding window).
girTime returns the time in milliseconds from some arbitrary origin; guaranteed to be comparable to the time value received by a handler function. FIXME: this may wrap around.
All other functions return NULL, and are invoked for their side effects.

Events

EVENT_CLOSE
: received when the user attempts to close the window.
EVENT_SIZE
: received when the window is resized. arg1 and arg2 are the new width and height of the window
EVENT_GAIN_FOCUS, EVENT_LOSE_FOCUS
: received when the window gets mouse/keyboard focus.
EVENT_REPAINT
: received when the window should redraw its contents, as directed by the windowing system.
EVENT_MOUSE_MOVE
: received when the mouse cursor moves in the window. arg1 and arg2 are the X and Y coordinates of the cursor.
EVENT_MOUSE_LBUTTON_UP,EVENT_MOUSE_LBUTTON_DOWN
:
EVENT_MOUSE_MBUTTON_UP,EVENT_MOUSE_MBUTTON_DOWN
:
EVENT_MOUSE_RBUTTON_UP,EVENT_MOUSE_RBUTTON_DOWN
: received when the given mouse button is pressed or released while the mouse cursor is inside the window. arg1 and arg2 are the X and Y coordinates of the cursor.
EVENT_MOUSE_WHEEL_UP,EVENT_MOUSE_WHEEL_DOWN
: received when the wheel moves while the mouse cursor is inside the window. arg1 and arg2 are the X and Y coordinates of the cursor.
EVENT_KEY_UP,EVENT_KEY_DOWN
: received when a key is pressed or released while the window has the keyboard focus. arg1 is the key code - all keys that produce printable characters are their unshifted selves; letters are uppercase; and the remaining keys are defined as GIR_KEY_* in gir.r.

See Also

girSetDoEvents, girCreateWindow, GIR_KEY


[Package gir version 0.3-2 Index]