Event arguments for the ValidateLabelText event.
Inheritance Hierarchy
EventArgs
InputModeEventArgs
LabelTextValidatingEventArgs
Remarks
Event handlers can set the cancel property to
true
to cancel label editing if validation failed, or set the newText property to a changed, validated value.Type Details
- yfiles module
- view-editor
- yfiles-umd modules
- view-editor, view-table, view
- Legacy UMD name
- yfiles.input.LabelTextValidatingEventArgs
Constructors
Initializes a new instance of the LabelTextValidatingEventArgs class.
Parameters
options - Object
A map of options to pass to the method.
A map of options to pass to the method.
- context - IInputModeContext
- The context.
- label - ILabel
- The label.
- newText - string
- The initial new text as entered by the user.
Properties
Gets or sets a value indicating whether the edit should be canceled.
Examples
Labels with tag "int label" should be rejected if their text cannot be parsed into an integer value:
mode.addValidateLabelTextListener((o, args) => {
if (args.label.tag === 'int label') {
args.cancel = Number.isNaN(parseInt(args.newText))
}
})
See Also
Gets the context for the current event.
Defined in
Gets the label that is being edited.
Remarks
Note that the label might not belong to a graph if it is a dummy for a label that is about to be created.
Examples
Labels with tag "int label" should be rejected if their text cannot be parsed into an integer value:
mode.addValidateLabelTextListener((o, args) => {
if (args.label.tag === 'int label') {
args.cancel = Number.isNaN(parseInt(args.newText))
}
})
Gets or sets the new text to use for the label.
Examples
Labels with tag "int label" should be rejected if their text cannot be parsed into an integer value:
mode.addValidateLabelTextListener((o, args) => {
if (args.label.tag === 'int label') {
args.cancel = Number.isNaN(parseInt(args.newText))
}
})
See Also
Gets or sets a Promise<T> resolving with the new text to use for the label.
Remarks
Resolving the Promise<T> with null
indicates that the edit should be canceled. If cancel is set to true
the result of the Promise<T> will be ignored.
Setting the new text or null
directly will also be accepted and handled just as if it would be the result of a Promise<T>.
Examples
Call an async method that checks if the new label text should be accepted:
mode.addValidateLabelTextListener(async (o, args) => {
// call checkIfTextIsValid which returns a Promise<bool>
args.validatedText = (await checkIfTextIsValid(args.newText))
? args.newText
: null
})