Class TextEditingTool

GoJS® Diagramming Components
version 3.0.1
by Northwoods Software®

Hierarchy

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.

For a general discussion of text editing validation, see: Introduction to Text Validation. For customizing the TextEditingTool, read about HTMLInfo and see Introduction to Text Editors.

Index

Constructors

Accessors

  • Gets or sets the HTMLInfo that is editing the text.

  • Gets or sets whether to select (highlight) the editable text when the TextEditingTool is activated. The default is true.

  • 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.

Methods

  • 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.

    This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

    Returns boolean

  • Abort any text editing operation.

    Returns void

  • 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.

    Parameters

    • oldstring: string
    • newstring: string

    Returns void

    since

    2.1

  • 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.

    Parameters

    • oldstring: string
    • newstring: string

    Returns void

    since

    2.1

  • 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.

    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.

    Parameters

    • textblock: TextBlock

      the TextBlock that is being edited.

    • oldstr: string

      the previous string value.

    • newstr: string

      the proposed new string value.

    Returns boolean

    true if the new string is valid for the given TextBlock.

  • This method returns a temporary TextBlock used for measuring text during editing. The TextBlock.text is set to the parameter's value, and the TextBlock is measured with the last available width of the textBlock.

    Text editors can use the GraphObject.measuredBounds and TextBlock.lineCount to determine a reasonable size for their text areas.

    Parameters

    • text: string

      the text to measure

    Returns TextBlock

Properties

deprecated

See TextEditingAccept.Enter.

deprecated

See TextEditingState.Active.

deprecated

See TextEditingState.Editing.

deprecated

See TextEditingState.Invalid.

deprecated

See TextEditingState.None.

deprecated

See TextEditingAccept.Tab.