Search
Controlling User Interaction

There are several ways to control user actions on the diagram as a whole, or on individual items in the diagram.

Specify How User's Actions are Interpreted

The Behavior property provides several predefined sets of rules specifying how user input with the mouse or keyboard is interpreted. If Behavior is set to LinkShapes, mouse dragging started from an unoccupied point of the document is processed as a ShapeNode creation request and dragging over a node creates a link.

 Note

Such behavior leads to some extra work when creating overlaying nodes - users need to draw the second node on an empty area and move it over the first one afterwards. If you want to avoid that, use the DrawShapes behavior.

If LinkTables is set, dragging the mouse over an empty area creates a table and dragging over a table creates a link. Behavior options also include DrawLinks, DrawTables and Modify.

Validation Events

The control raises various validation events during user interaction. While the user draws new items, there are the NodeCreating and LinkCreating events raised. While modifying existing items, there are the NodeModifying and LinkModifying events raised. Setting the Cancel argument to true prevents the operation being completed at the current location. Calling their CancelDrag method immediately stops the user interaction. When the user presses the Del key, the control raises NodeDeleting or LinkDeleting to give you a chance to prevent the operation.

Item Constraints

Constraints upon how users are allowed to modify a node are set through the Constraints and EnabledHandles properties. The former can be used to constrain the move direction, node size and aspect ratio. The latter enables or disables specific manipulation handles of a node. That allows making the node non-moveable, non-resizable, or resizable only horizontally/vertically.

Items can be locked by setting the Locked property. Locked items are excluded from selection and users cannot select, move or modify them.

Control How Links Connect to Nodes

The AllowIncomingLinks property of the DiagramNode class lets you specify whether incoming links can be drawn to a node. The AllowOutgoingLinks property lets you do that for outgoing links.
Anchor points define where link's ends should be placed when a user attaches a link to a node. A pattern of anchor points can be assigned to a node by setting the node's AnchorPattern. Additionally, the LinkCreating and LinkModifying validation events provide you with further control over the user's actions.

In-place Text Editing

The text of nodes and tables can be edited in-place by double-clicking the respective items. To enable the feature set the AllowInplaceEdit property to true. For tables, both captions and cells can be edited in this way. Depending on the type of item being edited, one of these events can be fired when editing completes: NodeTextEdited, LinkTextEdited. In-place editing mode is exited when users click outside the text entry control. Pressing ENTER or ESC exits in-place editing mode if respectively InplaceEditAcceptOnEnter and InplaceEditCancelOnEsc are enabled.

Miscellaneous

  • AllowMultipleResize specifies whether the user can resize multiple selected items simultaneously.
  • AllowUnconnectedLinks specifies whether the user is allowed to draw links that are not connected to a node.