OpenGLContext.events.eventmanager
Abstract base class for all event managers.
Classes
class BubblingEventManager(
EventManager
):
Manager base-class for events which support capture/bubbling
Capturing/bubbling is an idea taken from the DOM2
event API, basically, events traverse the scenegraph
hierarchy from scenegraph to node, then back up to
the scenegraph. At any point, the event can have its
stopPropagation attribute set, which will prevent
processing the next node in the set.
It is also possible to capture/bubble events
"anonymously", that is, before/after the traversal
described above (which is ~ what you get with regular
EventManager classes (save that there are two points
of registration, capture and bubble, and the capture
phase can stopPropagation to avoid all further
processing)).
Events compatible with this manager require the following
in addition to normal Event instances:
stopPropagation = 0
processMorePaths = 0
def getObjectPaths( self ):
the following attributes will be added during traversal:
currentPath = ()
currentNode = None
atTarget = 0
class EventManager(
object
):
Abstract base class for all event managers.
Event managers are responsible for dispatching events
of a particular type to registered handling functions
in response to dispatches from the Context's ProcessEvent
method.
This class is primarily of interest to those wishing to
create new event classes or "capture" event managers.
It is necessary to define a new EventManager class
for each event type to be handled.
For new event classes, the primary point of interest is the
registerCallback function, which needs to be defined so
that clients can define new keys for dispatching.
For capture event managers (managers which are responsible
for "modal" operation), overriding the ProcessEvent
method is likely the most appropriate approach.
_removeCurrentCallbacks(
cls
,
key
,
node
= None
,
capture
= 0
)
De-register current callbacks, return previous callback
Note:
There should only ever be one receiver registered
this way, so should always be either None or the
previous callback.
ProcessEvent(
self
,
event
)
Dispatch an incoming event
The event must define the getKey() method.
The event must have an attribute "type" (though the current
implementation does not actually use this, the information
should be available in ambiguous circumstances).
registerCallback(
cls
,
key
,
function
= None
,
node
= None
,
capture
= 0
)
Register callback function for the given key (possibly node-specific)
- key
- as returned by event.getKey()
- function
- callable function taking at least an event object as it's first parameter, or None
- node
- the node to be watched, None to register a context-level callback ( default )
- capture
- if true, capture events before passing to children, rather than processing during the bubbling phase. (default false)
Note: this method would normally be called by a sub-
class with the calculated key for the sub-class.
return previous callback function or None