Class TextEditingTool
Extends Tool. 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
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
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.
Constructor Summary Details
Returns | Name | Description |
---|---|---|
TextEditingTool()
|
You do not normally need to create an instance of this tool
because one already exists as the ToolManager.textEditingTool, which you can modify. More...
The Tool.name of this tool is "TextEditing". |
Properties Summary Details
Returns | Name | Description |
---|---|---|
{Element}
|
currentTextEditor
|
Gets or sets the HTML element that is editing the text.
|
{Element}
|
defaultTextEditor
|
Gets or sets the default HTML element that edits the text. More...
This is used by TextEditingTool.doActivate in case the TextBlock does not provide a TextBlock.textEditor.
The HTML element will be added and removed automatically, and
should have a way of calling TextEditingTool.acceptText.
By default the value is an HTMLTextArea.
|
{boolean}
|
selectsTextOnActivate
1.5
|
Gets or sets whether to select (highlight) the editable text when the TextEditingTool is activated. More...
The default is true.
|
{EnumValue}
|
starting
|
Gets or sets how user gestures can start in-place editing of text. More...
Possible values are TextEditingTool.SingleClickSelected and TextEditingTool.SingleClick The default is TextEditingTool.SingleClickSelected |
textBlock
|
Gets or sets the TextBlock that is being edited. More...
This property is initially null and is set in TextEditingTool.doActivate
as the TextBlock at the mouse click point.
However, if you set this property beforehand, TextEditingTool.doActivate
will not set it, and this tool will edit the given TextBlock.
|
|
{function(TextBlock, string, string):boolean | null}
|
textValidation
|
Gets or sets the predicate that determines whether or not a string of text is valid. More...
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. |
Method Summary Details
Returns | Name | Description |
---|---|---|
acceptText(reason)
|
Finish editing by trying to accept the new text. More...
Please read the Introduction page on Extensions for how to override methods and how to call this base method.
|
|
{boolean}
|
canStart()
|
This may run when there is a mouse-click on a TextBlock for which the
TextBlock.editable property is true in a Part
that Part.isSelected. More...
This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.
|
doActivate()
|
Start editing the text for a textBlock. More...
If TextEditingTool.textBlock is not already specified, this looks for one at the current mouse point. If none is found, this method does nothing.
Then this method need an HTMLElement to manage the editing. If TextBlock.textEditor
is defined on the 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. |
|
doCancel()
|
Abort any text editing operation.
|
|
doDeactivate()
|
Release the mouse.
|
|
doMouseDown()
|
This calls acceptText with the reason TextEditingTool.MouseDown,
if this tool Tool.isActive.
|
|
doMouseUp()
|
A click (mouse up) calls TextEditingTool.doActivate if this tool is not already active
and if TextEditingTool.canStart returns true.
|
|
doStart()
|
This calls TextEditingTool.doActivate if there is a
textBlock set. More... doActivate attempts to set textBlock if it is null.
|
|
{boolean}
|
isValidText(textblock, oldstr, newstr)
|
This predicate checks any TextBlock.textValidation predicate and
this tool's textValidation predicate to make sure the TextBlock.text
property may be set to the new string. More...
This method may be overridden, although usually it is sufficient to set textValidation. Please read the Introduction page on Extensions for how to override methods and how to call this base method.
|
- Methods borrowed from class Tool:
- cancelWaitAfter, canStartMultiTouch, doKeyDown, doKeyUp, doMouseMove, doMouseWheel, doStop, doWaitAfter, findToolHandleAt, isBeyondDragSize, standardMouseClick, standardMouseOver, standardMouseSelect, standardMouseWheel, standardPinchZoomMove, standardPinchZoomStart, standardWaitAfter, startTransaction, stopTool, stopTransaction, updateAdornments
Constants Summary Details
Returns | Name | Description |
---|---|---|
<constant> {EnumValue} |
Enter
|
A possible value for TextEditingTool.acceptText, the user has typed ENTER.
|
<constant> {EnumValue} |
LostFocus
|
A possible value for TextEditingTool.acceptText, the text editing control has lost focus.
|
<constant> {EnumValue} |
MouseDown
|
A possible value for TextEditingTool.acceptText, the user has clicked somewhere else in the diagram.
|
<constant> {EnumValue} |
SingleClick
|
A possible value for TextEditingTool.starting,
A single click on a TextBlock with TextBlock.editable property set to true
will start in-place editing.
|
<constant> {EnumValue} |
SingleClickSelected
|
A possible value for TextEditingTool.starting,
A single click on a TextBlock with TextBlock.editable property set to true
will start in-place editing, but only if the Part that the TextBlock is in is already selected.
|
<constant> {EnumValue} |
Tab
|
A possible value for TextEditingTool.acceptText, the user has typed TAB.
|