Search
In-place Editing the Contents of Items

Standard in-place editing

To activate the standard in-place editing of the text of MindFusion.Diagramming objects, set the AllowInplaceEdit property to true. AllowInplaceEdit allows in-place editing the content of a diagram element by double-clicking it. In-place editing mode can be accepted and exited by clicking anywhere outside the text-field.

If you want to change the way of accepting / rejecting changes, the following DiagramView properties allow using the ENTER and ESC keys to perform that: InplaceEditAcceptOnEnter and InplaceEditCancelOnEsc. When InplaceEditAcceptOnEnter is set to true, pressing the ENTER key causes accepting changes and exiting in-place editing mode. If InplaceEditAcceptOnEnter is set to false, pressing ENTER inserts a new line in the text while in in-place editing mode. If InplaceEditCancelOnEsc is set to true, pressing the ESC key performs rejecting changes and exiting in-place editing mode.

In-place editing can be applied to the following properties: ShapeNode.TextDiagramLink.Text, TableNode.Cell.Text, TableNode.Caption and ContainerNode.Caption. For tables, both captions and cells can be edited in this way.

If you want to enable/disable in-place editing of a specific table's cell, handle the CellTextEditing event. To enable/disable in-place editing of nodes, handle the NodeTextEditing event. For a DiagramLink object, the LinkTextEditing event is raised while in-place editing. These validation events let you prevent users from editing the text in the particular object if it is necessary.

When in-place editing of a node is completed, the NodeTextEdited event is raised. For a table's cell, handle the CellTextEdited event. LinkTextEdited event is raised when in-place editing of a DiagramLink object completes.

By default, MindFusion.Diagramming creates an HTML textarea element to let users edit item's text. The EnterInplaceEditMode event allows customizing the properties of that control, or attaching event handlers to it. InplaceEditFont specifies the font of the in-place edited text box. Actually, InplaceEditFont is assigned to the Font property of that text box.

When leaving in-place editing mode, the LeaveInplaceEditMode event is raised. This event is raised in all cases of closing the in-place editing control, for example, when the user accepts or cancels the changes made to an item's text, or when the EndEdit method is called.

To enter in-place editing mode programmatically and let users edit an item's text inline, call the BeginEdit method of DiagramView. The EndEdit method exits in-place editing mode.

In-place editing of custom items

The InplaceEditable interface allows implementing the standard in-place editing for custom defined items. By means of the methods of this interface, you can specify the position of the in-place editing textbox control and copy the entered text to a property of the edited item.

GetEditRect returns the destination rectangle of the in-place editing box. GetTextToEdit represents the initial contents of the in-place editing box. SetEditedText sets the edited text to the object after completing the in-place editing.