The TextEditingTool is used to let the user interactively edit text in place. This sets the TextBlock.text property; you may want to save the changed text to the model by using a TwoWay Binding on the "text" property of editable TextBlocks.
Typically this is used by setting the TextBlock.editable property to true on a particular TextBlock in a part. When the part is selected and the user clicks on the TextBlock or invokes the CommandHandler.editTextBlock command, this tool is started and it uses an HTMLTextArea to perform in-place text editing. (For more details see the description for TextEditingTool.doActivate.)
The TextBlock is accessible as the TextEditingTool.textBlock property. The text editor is accessible as the TextEditingTool.currentTextEditor property. From the text editor control one can access the TextBlock being edited via the 'textEditingTool' property to get to this tool, from which one can use the TextEditingTool.textBlock property.
You can disable mouse clicking from starting this text editing tool by setting Tool.isEnabled to false. You can disable the F2 key from starting this text editing tool by making sure Part.canEdit returns false, by either setting Diagram.allowTextEdit to false or by setting Part.textEditable to false.
If you want to programmatically start the user editing a particular TextBlock, call CommandHandler.editTextBlock. That command method is also invoked by the F2 key on the keyboard.
Gets or sets the HTMLInfo that is editing the text.
Gets or sets the default HTMLInfo that edits the text.
For typical operation, HTMLInfo implementations should have a way of calling TextEditingTool.acceptText.
Gets or sets whether to select (highlight) the editable text when the TextEditingTool is activated. The default is true.
Gets or sets the state of the TextEditingTool. The only accepted values are listed as constant properties of TextEditingTool, including:
The starting value value is TextEditingTool.StateNone, TextEditingTool.doActivate sets the value to TextEditingTool.StateActive. The default text editor receiving focus sets the value to TextEditingTool.StateEditing. TextEditingTool.acceptText sets the value to TextEditingTool.StateValidating. Once accepted and the tool begins the "TextEditing" transaction, the value is set to TextEditingTool.StateValidated.
Gets or sets the predicate that determines whether or not a string of text is valid. If this is non-null, this predicate is called in addition to any TextBlock.textValidation predicate. See isValidText for more details. The default predicate is null, which is equivalent to simply returning true.
The function, if supplied, must not have any side-effects.
Finish editing by trying to accept the new text.
Please read the Introduction page on Extensions for how to override methods and how to call this base method.
Start editing the text for a textBlock.
If TextEditingTool.textBlock is not already specified, this looks for one at the current mouse point. If none is found, this method does nothing.
This method sets currentTextEditor.
If TextBlock.textEditor is defined on the TextBlock it will use that as the value.
By default, it uses the value of defaultTextEditor, which is an HTMLInfo
showing an HTML textarea, with the CSS class
This sets Tool.isActive to true. Custom text editors should call TextEditingTool.acceptText to finish the edit by modifying the TextBlock and committing the edit transaction. Or call TextEditingTool.doCancel to abort the edit.
Abort any text editing operation.
Call the textBlock's TextBlock.errorFunction, if there is one, and then show the text editor again. This is called only when the isValidText method returned false. The value of state will be StateInvalid. This method may be overridden. You may wish to override this method in order to not continue showing the editor.
Call the textBlock's TextBlock.textEdited event handler, if there is one. This is called just after the TextBlock.text has been set to the new string value. When this method returns, this tool raises the "TextEdited" DiagramEvent and commits the transaction. This method may be overridden.
the TextBlock that is being edited.
the previous string value.
the proposed new string value.
true if the new string is valid for the given TextBlock.
A possible value for TextEditingTool.acceptText, the user has typed ENTER.
A possible value for TextEditingTool.acceptText, the text editing control has lost focus.
A possible value for TextEditingTool.acceptText, the user has clicked somewhere else in the diagram.
A possible value for state, this is the starting value before the tool is activated.
A possible value for TextEditingTool.acceptText, the user has typed TAB.