Diagram Events
There are various events raised after user interaction in SwiftDiagram. These events are accessible as static fields of the Events class. Event listeners can be attached to a Diagram
instance through respective event fields.
The following sample code attaches an event listener to the nodeCreated
event. The variable diagram identifies a Diagram
object. The declaration of all event handlers should look similar to the following, with a sender event specifying the diagram, and an args argument that is an instance of event class such as NodeEventArgs
or LinkEventArgs
.
//add the listener
diagram.nodeCreated += {
sender, args in
print("Node created at point: (\(args.node.bounds.x) , \(args.node.bounds.y))")
}