A Sheet can emit a number of different events which consumers can subscribe to. Note that all the event identifies correspond to strings, however, it is recommended to use the identifies to prevent disruption in the event that the underlying string changes.
Use the Sheet.on()
method to add an event handler:
sheet.on(GraphPaper.SheetEvent.CLICK, (eventData) => {
// a click occured
});
Use the Sheet.off()
method to remove an event handler:
sheet.off(GraphPaper.SheetEvent.CLICK, registeredCallbackFunction);
Emitted when the user clicks or taps anywhere on the sheet.
The event object contains the following fields:
{
targetPoint, // GraphPaper.Point of the clicked location
entityClicked, // Entity object if an entity was clicked, null otherwise
}
Emitted when the user double-clicks or double-taps an empty area of the sheet
The event object contains the following fields:
{
targetPoint, // GraphPaper.Point of the double-clicked location
entitiesAroundPoint, // Array with entities at/around the double-clicked location (within 1px)
}
Emitted when a selection box, possibly containing multiple entities, has been created
The event object contains the following fields:
{
selectedEntities, // Array of entities within the selection box
boundingRect, // GraphPaper.Rectangle representing the selection box
}
Emitted when the user has triggered the creation of a selection box (typically by pressing and holding the the primary mouse button).
The event object contains the following fields:
{
x, // x-coordinate where selection box creation started
y, // y-coordinate where selection box creation started
}
Emitted when an entity has been added to the sheet.
The event object contains the following fields:
{
object, // The Entity that was added to the Sheet
}
Emitted when an entity has been removed from the sheet.
The event object contains the following fields:
{
object, // The Entity that was removed from the Sheet
}
Emitted when an entity has been resized.
The event object contains the following fields:
{
entity, // The Entity that has been resized
}
Emitted when an entity has been translated.
The event object contains the following fields:
{
object, // The Entity that has been translated
withinGroupTransformation, // Flag indicating if the translation was part of a group transformation
}
These events are only emitted if the Connector Routing Worker is enabled.
Emitted when a connector connecting entities has been updated in some way.
The event object contains the following fields:
{
connector, // The connector that was updated
}
These events are only emitted if the Cluster Detection Worker is enabled.
Emitted when a new Cluster has been created.
The event object contains the following fields:
{
cluster, // Newly created Cluster
}
Emitted when an entity has been added or removed from a Cluster.
The event object contains the following fields:
{
cluster, // Newly created Cluster
}
Emitted when a Cluster has been deleted.
The event object contains the following fields:
{
clusterId, // string with ID of Cluster that was deleted
}