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 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. Additional members of the Behavior
enumeration provide more limited interaction modes.
In-place Text Editing
The text of nodes and links can be edited in-place by double-clicking the respective items. Depending on the type of item, the control raises either the nodeTextEdited
, cellTextEdited
or linkTextEdited
event when its text has been edited. In-place editing mode is exited when users click outside the text entry control. By default, the control creates a UITextView control over an item to allow editing the item’s text. You can learn useful data about the text edit from the EditNodeTextEventArgs
, EditLinkTextEventArgs
and EditTreeItemTextEventArgs
classes.
Validation Events
The NodeEventArgs
class provides data for events raised when nodes are modified. The node
property gives the node that raised the event, pointerPosition
and adjustmentHandle
provide additional information about the position of the coursor and the node handle that was used to generate the event. By setting the cancel
property of the event object, you can prevent the operation from being completed at the current position but let the user continue drawing. Calling the cancelDrag
method immediately stops the operation. The nodeModifying
and linkModifying
events provide the same functionality during modification of existing objects. Finally, if the user tries to delete an item, you can handle the nodeDeleting
or linkDeleting
event to prevent this.