This module defines the EventManager class which is used to manage events. An event is something that occurs at a particular time and that might trigger actions. Each type of event has to be identified by a unique name and each occurrence of an event can be associated with arbitrary data (for example, if a key press occurs the data contains the key code).
When dealing with events you have to consider two parts. One part is producing the events and the other part is consuming them. And it is the EventManager that acts as a broker between the two. Whenever an event occurs the producer tells the event manager about the event and the event manager takes care of notifying anyone who showed interest in this type of event. This way, the producer and consumer don't have to know each other but can rely on the event manager who is always present (whereas a particular producer or consumer might not be available all the time).
The event manager distinguishes between system wide events and normal events. Normal events are those that have a relationship with the current scene and that are removed if the scene is cleared. On the other hand, system wide events are independent from the current scene and remain intact if the scene is cleared.
There is always a global event manager instance that should be used for managing all events:
| ) |
| ) |
| name, *params, **keyargs) |
The method returns True if any of the event handlers returned
True (i.e. the event was consumed). In this case, the notification
chain was interrupted. This means, any event handler that would have been
called after the one that returned True was not called anymore.
| name, receiver, priority=10, system=False) |
onname() method. priority determines the order in
which the receivers are invoked. Receivers with lower values (=high priority)
are invoked first.
The argument system specifies if the connection is system wide or not.
| name, receiver=None, system=False) |
None then all connections from the event
are removed. The argument system specifies if the connection is
system wide or not.
| system=False) |