click property
Gets or sets the function to execute when the user single-primary-clicks on this object.
This typically involves a mouse-down followed by a prompt mouse-up
at approximately the same position using the left (primary) mouse button.
This property is used by the ClickSelectingTool
when the user clicks on a GraphObject.
The function is called in addition to the DiagramEvent
that is raised with the name "ObjectSingleClicked"
.
If this property value is a function, it is called with an InputEvent and this GraphObject. The InputEvent#targetObject provides the GraphObject that was found at the mouse point before looking up the visual tree of GraphObject#panels to get to this object.
From the second argument, obj, you can get to the Node or Link via the #part property.
From there you can access the bound data via the Panel#data property.
So from an event handler you can get the bound data by obj.part.data
.
By default this property is null.
Objects in Layers that are Layer#isTemporary do not receive click events. If you do want such objects to respond to clicks, set #isActionable to true.
If you do provide a function that makes changes to the diagram or to its model, you should do so within a transaction -- call Diagram#startTransaction and Diagram#commitTransaction.
An example of a click event handler is shown in the Arrowheads sample.
Implementation
void Function(
_i3.InputEvent,
_i3.GraphObject,
)? get click => (
_i3.InputEvent p0,
_i3.GraphObject p1,
) =>
_i4.callMethod(
_i4.getProperty(
this,
'click',
),
r'call',
[
this,
p0,
p1,
],
);
Implementation
set click(
void Function(
_i3.InputEvent,
_i3.GraphObject,
)? value) {
_i4.setProperty(
this,
'click',
value == null ? _i5.undefined : _i4.allowInterop(value),
);
}