Event System¶
The event system in Gaphor provides an API to handle events and to subscribe to events.
In Gaphor we manage event handler subscriptions through the EventManager
service. Gaphor is highly event driven:
Changes in the loaded model are emitted as events
Changes on diagrams are emitted as events
Changes in the UI are emitted as events
Although Gaphor depends heavily on GTK for its user interface, Gaphor is using
its own event dispatcher. Events can be structured in hierarchies. For example,
an AttributeUpdated
event is a subtype of ElementUpdated
. If we are interested
in all changes to elements, we can also register ElementUpdated
and receive all
AttributeUpdated
events as well.
- class gaphor.core.eventmanager.EventManager[source]¶
The Event Manager.
- priority_subscribe(handler: Callable[[object], None]) None [source]¶
Register a handler.
Priority handlers are executed directly. They should not raise other events, cause that can cause a problem in the exection order.
It’s basically to make sure that all events are recorded by the undo manager.
Under the hood events are handled by the Generics library. For more information about how the Generic library handles events see the Generic documentation.