documentationfor yFiles for HTML 3.0.0.3

EditLabelInputMode

Handles interactive editing and adding of labels.

Inheritance Hierarchy
EditLabelInputMode
Implemented Interfaces

Remarks

Label adding or editing using the text editor can be triggered from code by calling startLabelAddition, startLabelEditing, or the respective methods on GraphEditorInputMode or TableEditorInputMode. This input mode also handles label adding or editing triggered by commands.

The actual text editor is opened using the textEditorInputMode.

This input mode relies on the IEditLabelHelper implementation found in a ILabel's or ILabelOwner's lookup. By default, all labels and label owners provide a suitable implementation. Custom implementations may be provided by decorators.

Using a custom edit label helper for nodes
graph.decorator.nodes.editLabelHelper.addConstant(new EditLabelHelper())

At the beginning of a label adding or editing operation, IEditLabelHelper's initialize is called for preparations but also for optional information, like styles. Custom implementations might also keep state. It is guaranteed that for each initialized helper either cancel or finish is called.

It is possible to validate new label text before the editor is closed and the label's text is changed or a new label is added.

Validating the label text
graphEditorInputMode.editLabelInputMode.addEventListener(
  'validate-label-text',
  (evt) => {
    if (
      evt.label.tag === 'int label' &&
      Number.isNaN(parseInt(evt.newText))
    ) {
      evt.validatedText = null
    }
  },
)

If label editing was successful, EditLabelInputMode delegates to IEditLabelHelper's finish method which takes care of actually setting the label text or adding a new label or removing the edited label.

Examples

Typically the EditLabelInputMode is installed as child mode of a GraphEditorInputMode and can be retrieved from the editLabelInputMode property.
Getting the EditLabelInputMode from its parent input mode
const editLabelInputMode = mode.editLabelInputMode

Related Reading in the Developer's Guide

An overview of this input mode is given in the section Adding and Editing Labels.

Type Details

yFiles module
view

See Also

Constructors

Properties

Methods

Events