An IEditLabelHelper implementation which provides a number of methods that can be overridden to change the default behavior.
Remarks
Examples
class CustomEditLabelHelper extends BaseClass(EditLabelHelper) {
protected onLabelAdding(
context: IInputModeContext,
evt: LabelEditingEventArgs,
): void {
// let the base implementation do the work
super.onLabelAdding(context, evt)
// for new edge labels: use a custom parameter
if (evt.owner instanceof IEdge) {
evt.layoutParameter =
new EdgeSegmentLabelModel().createParameterFromCenter()
}
}
}
graph.decorator.edges.editLabelHelper.addConstant(
new CustomEditLabelHelper(),
)
Type Details
- yFiles module
- view
Properties
Gets or sets the graph instance to retrieve the default values from.
Remarks
Property Value
Methods
Handles adding the label upon finish.
Remarks
null
, the context
is asked for a graph implementation. If no graph is retrieved, null
is returned.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The valid input mode context for this action.
- evt - LabelEditingEventArgs
- A template to get all properties to create the label from. Note that the preferredSize can be
null
. In this case it will be determined automatically.
Returns
- ↪ILabel?
- The newly created label, or
null
if no graph is available.
Invoked if the label editing action has been canceled.
Remarks
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The current input mode context.
- evt - LabelEditingEventArgs
- Additional information about the label or label owner and whether the editing operation has been canceled programmatically.
Implements
Invoked after the label editing gesture has successfully finished.
Remarks
Completes the gesture by applying the changes, according to action
.
Depending on action
, this method delegates to addLabel, setLabelText, removeLabel, and labelDropped.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context from the input mode which invoked that method.
- evt - LabelEditingEventArgs
- The LabelEditingEventArgs which provide the information for the label to be added or edited. In particular, the owner for newly added labels or the label to edit or remove, and the text to set
- action - LabelEditingAction
Returns
- ↪ILabel?
- The added, edited, or removed label if the action has been completed successfully.
null
, otherwise.
Implements
Obtains the defaults for the label owner.
Remarks
context
and, if one is returned, to get the defaults from that graph.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context
- owner - ILabelOwner
- The owner to get the label defaults for
Returns
- ↪ILabelDefaults?
- The label defaults.
Determines the label model parameter to use for the label, depending on the owner
.
Remarks
owner
.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- owner - ILabelOwner
- The label's owner.
Returns
- ↪ILabelModelParameter?
- The layout parameter to use or
null
.
Determines the style to use for the label, depending on the owner
.
Remarks
owner
.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- owner - ILabelOwner
- The label's owner.
Returns
- ↪ILabelStyle?
- The style to use or
null
.
Gets the preferred size for the label.
Remarks
null
to indicate that the preferred size should be calculated after the text has been entered.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- label - ILabel
- The label to get the preferred size from.
Returns
- ↪Size?
- The size to use or
null
.
Invoked at the beginning of a label adding or label editing gesture.
Remarks
action
.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context from the input mode which invoked that method.
- evt - LabelEditingEventArgs
- A configuration object which supports customizing the label editing.
- action - LabelEditingAction
Implements
Handles adding the label upon finish after the drop action of a drag and drop operation.
Remarks
evt
' owner. If this helper's graph is not null
, said instance is used to add the label. If graph is null
, this implementation tries to retrieve a graph from the given context
. If the retrieved graph is not null
, said instance is used to add the label. If the retrieved graph is null
, this implementation returns null
without adding a label.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The valid input mode context for this action.
- evt - LabelEditingEventArgs
Returns
- ↪ILabel?
- The newly created label.
Will be called from initialize to initialize the helper for ADDing labels.
Remarks
evt
and sets the handled property to true
. Label creation thus is always possible and will be handled by this instance.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- evt - LabelEditingEventArgs
- The original event arguments.
Invoked from initialize to initialize the helper for adding labels after the drop action of a drag and drop operation.
Remarks
Called by LabelDropInputMode when a label is dropped on the owner.
This implementation does nothing.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- evt - LabelEditingEventArgs
- The original event arguments.
Will be called from initialize to initialize the helper for EDITing labels.
Remarks
If label is set, this implementation does nothing which means that this label will be edited normally.
If label is null
but owner is not null
, this method sets the label of the given evt
to the first of the labels that belong to said owner. If no label is found, this method sets the properties of the given evt
to the values returned by getLabelParameter, getLabelStyle, and getPreferredSize to prepare defaults for label adding.
This method always sets the handled property of the given evt
to true
, so label editing is always possible and will be handled by this EditLabelHelper instance.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- evt - LabelEditingEventArgs
- The original event arguments.
onLabelPasting
(context: IInputModeContext, evt: LabelEditingEventArgs, newOwner: ILabelOwner, originalLabel: ILabel)Invoked from initialize to initialize the helper for adding labels during paste from the GraphClipboard.
Remarks
Called by GraphClipboard when a label is pasted.
This implementation uses getLabelParameter to provide a suitable layoutParameter if the item type of the model changed.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The input mode context.
- evt - LabelEditingEventArgs
- The original event arguments.
- newOwner - ILabelOwner
- The owner the new label will be pasted on.
- originalLabel - ILabel
- The original of the new label.
Handles removing the label upon finish.
Remarks
null
, the context
is asked for a graph implementation. If no graph is retrieved, null
is returned.Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The IInputModeContext.
- label - ILabel
- The label to remove.
Returns
- ↪boolean
- Whether a label was removed.
Handles changing the label text upon finish.
Remarks
This implementation uses setLabelText to add the label to the graph. The graph is tried to retrieve from graph first. If graph is null
, the context
is asked for a graph implementation. If no graph is retrieved, null
is returned.
If the label's text is not changed, null
is returned.
Parameters
A map of options to pass to the method.
- context - IInputModeContext
- The IInputModeContext.
- label - ILabel
- The label on which to set the text.
- text - string
- The text to set on the label.
Returns
- ↪boolean
- Whether a new label text was set.