OpenGLContext.events.eventhandlermixin
Mix in functionality for Context classes needing event support
Classes
class EventHandlerMixin(
object
):
This class provides mix in functionality for contexts
needing event support.
Contexts wishing to support particular types of event will
store pointers to each of the appropriate manager classes in
their EventManagerClasses attribute before calling the
EventHandlerMixin.initializeEventManagers() method. The format
for EventManagerClasses is [ ("eventType", managerClass), ... ].
Clients wishing to register particular event handlers will use
addEventHandler method to register each event handler.
Clients wishing to capture all events of a particular type for
a limited duration will use the captureEvents method, passing
in a pointer to an event manager which will handle the updates.
The event handler mix in provides a client API for the registration
and handling of events.
addEventHandler(
self
,
eventType
,
*
arguments
,
**
namedarguments
)
Add a new event handler function for the given event type
This is the primary client API for dealing with the event system.
Each event class will define a particular set of data values
required to form the routing key for the event. Each event handler
class will define a registerCallback function which converts
its arguments into a matching key.
This function merely determines the appropriate handler then
dispatches to the handler's registerCallback method (without the
eventType argument).
See: mouseevents, keyboardevents
addEventManager(
self
,
eventType
,
manager
= None
)
Add an event manager to the internal table of managers.
The return value is the previous manager or None if there was
no previous manager.
captureEvents(
self
,
eventType
,
manager
= None
)
Temporarily capture events of a particular type.
This temporarily replaces a particular manager within the
dispatch set with provided manager. This will normally be
used to create "modal" interfaces such as active drag
functions (where the interface is in a different "interaction
mode", so that actions have different meaning than in the
"default mode").
Passing None as the manager will restore the previous manager
to functioning.
Note: this function does not perform a "system capture"
of input (that is, mouse movements are only available if they
occur over the context's window and that window has focus).
Note: for capturing mouse input, you will likely want to
capture both movement and button events, it should be possible
to define a single handler to deal with both event types,
and pass that handler twice, once for each event type.
DoEventCascade(
self
)
Do pre-rendering event cascade
Returns the total number of events generated by
timesensors and/or processed from the event cascade queue
getEventManager(
self
,
eventType
)
Retrieve an event manager from the internal table of managers
Returns the appropriate manager, or None if there was no
manager registered for the given event type.