C

GraphInputMode
abstract

Abstract base class for GraphViewerInputMode and GraphEditorInputMode.
ImplementsInheritance Hierarchy

Remarks

This class is not supposed to and in fact cannot be extended from user code. It only exists to provide common functionality to the two aforementioned input modes. If customizations are wanted or needed, both GraphViewerInputMode and GraphEditorInputMode can be extended.

This class cannot be instantiated

Members

Show:

Properties

Gets or sets a property that determines whether clipboard operations with the usual shortcuts are enabled on the canvas.
Default value is true
final

Examples

Disabling clipboard operations
mode.allowClipboardOperations = false
Gets a collection of commands that this input mode will handle.
This collection can be modified by removing commands to prevent the input mode from handling them. Previously removed commands can also be re-added again to enable them again. However, the input mode will never handle commands that weren't in the initial collection. Adding those will do nothing.
readonlyfinal
Gets or sets which types of items should be reported through the item click events.

This also affects taps.

The default is ALL.

conversionfinal

Examples

mode.clickableItems = GraphItemTypes.NODE | GraphItemTypes.EDGE

See Also

API
clickablePredicate
Gets or sets a predicate that is queried to determine whether an item can be clicked.
The default value returns the result of the clickableItems property for the given item.
final

See Also

API
clicked, click
Gets or sets the order of the types of items that should be used to determine what item has been clicked or tapped.

Change this field to adjust which items will be selected if there are multiple items at a given location. The default order is the Z-Order but with a prioritization for elements behind labels. shouldSkipHitLabel.

Arrays that contain strings describing the name of GraphItemTypes are converted to an array of GraphItemTypes. For example:

['node', 'edge']
['NODE', 'EDGE']
final

Examples

The following example defines the order 1. bends, 2. nodes and edges (with equal priority), 3. labels.
mode.clickHitTestOrder = [
  GraphItemTypes.BEND,
  GraphItemTypes.NODE | GraphItemTypes.EDGE,
  GraphItemTypes.LABEL,
]

See Also

API
clickSelectableItems, selectableItems, findItems
Gets or sets the ClickInputMode that is used by this instance to determine clicks.

Whenever the mode detects a click, this mode will use the IHitTester from the parentInputModeContext to determine the items being hit. If they match the clickableItems type, the item-clicked event will be triggered. If they are focusable, the item will be set as the current item.

Upon change, the onClickInputModeChanged method will be called.

By default, this input mode has a priority of 20.

final

Examples

Disabling the ClickInputMode on its parent input mode
mode.clickInputMode.enabled = false

See Also

API
onItemClicked
Gets or sets which types of items should be selectable by mouse clicks.
The default is ALL.
conversionfinal

Examples

Determine which items should be selectable by different selection gestures
// Nodes, edges, and bends are selectable
mode.selectableItems =
  GraphItemTypes.NODE | GraphItemTypes.EDGE | GraphItemTypes.BEND
// Only nodes and bends are selectable by marquee selection
mode.marqueeSelectableItems = GraphItemTypes.NODE | GraphItemTypes.BEND
// Only nodes and edges are selectable by click selection
mode.clickSelectableItems = GraphItemTypes.NODE | GraphItemTypes.EDGE

See Also

API
clickSelectablePredicate, setSelected
Gets or sets a predicate that is queried to determine whether an item should be selected when clicked with the primary mouse button.
The default value returns the result of selectablePredicate and the clickSelectableItems property for the given item.
final

See Also

API
clicked, click
Gets or sets the ContextMenuInputMode which handles context menus on a CanvasComponent.

Upon change, the onContextMenuInputModeChanged method will be called.

By default, this input mode has a priority of 220.

final

Examples

Disabling the ContextMenuInputMode on its parent input mode
mode.contextMenuInputMode.enabled = false
It is recommended to configure the context menu handling on the parent GraphEditorInputMode or GraphViewerInputMode instead of the contextMenuInputMode. This involves registering for the populate-item-context-menu event instead of the populate-menu event:
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.contextMenuItems = GraphItemTypes.NODE
mode.addEventListener('populate-item-context-menu', (evt) => {
  // Get the node which is handled or null if the item is not a node
  const node = evt.item
  // Create the context menu items
  if (node !== null) {
    // Create a menu item to delete the node

    // Show the menu
    evt.contextMenu = [
      { label: 'Delete Item', action: () => graph.remove(node) },
    ]
  }
})
Gets or sets the types of items a context menu should be queried for.
The items for which a context menu should be queried. The default value is NODE|EDGE.
conversionfinal

Examples

// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.contextMenuItems = GraphItemTypes.NODE
mode.addEventListener('populate-item-context-menu', (evt) => {
  // Get the node which is handled or null if the item is not a node
  const node = evt.item
  // Create the context menu items
  if (node !== null) {
    // Create a menu item to delete the node

    // Show the menu
    evt.contextMenu = [
      { label: 'Delete Item', action: () => graph.remove(node) },
    ]
  }
})
Gets the installed controller.
protectedreadonlyfinal
Gets or sets the event recognizer that determines if a click or tap should cycle through all the items that are currently under the mouse cursor.

If the recognizer determines that the user wanted to use the cyclic click selection behavior, the hitTester will be queried for the given item and previously reported items will be ignored. E.g. if multiple nodes are overlapping each other, clicking on them will report the first item for the first click, the second one for the second click and so on. If all elements have been reported previously, the first one is going to be reported again. If the order of the elements at the clicked location changes, the cyclic selection is restarted anew.

The default is ALT_IS_DOWN.

final

Property Value

An event recognizer which determines that the user wants to use the cyclic click selection behavior.

Sample Graphs

ShownSetting: Alt pressed / cyclic selection recognizer returns true: repeated clicking at a location cycles through the elements at that location (the X).
Gets or sets the cursor to use whenever no child mode prefers a different cursor.
The default is null
conversionfinal

See Also

Developer's Guide
API
adjustCursor
Gets or sets the event recognizer that determines if a click or tap should select the item that is currently visible under the pointer cursor, without giving more important items higher priority.

If the recognizer determines that the user wanted to use the detail clicking behavior, the hitTester will be queried for the given item and the first item that is returned will be considered a hit. Otherwise, all hit items are examined and are prioritized by item type. E.g. by default clicking on a node will select the node, even if there is a node label which has been clicked at the same point. If detail selection is recognized, the label will be selected.

The default is SHIFT_IS_DOWN.

final

Property Value

An event recognizer which determines that the user wants to use the detail clicking behavior.

Examples

mode.detailSelectionRecognizer = EventRecognizers.SHIFT_IS_DOWN

Sample Graphs

ShownSetting: No Shift / detail selection recognizer returns false: click on the label selects the higher prioritized node.
Gets or sets a predicate that is queried to determine whether an item can be double clicked.
The default value returns the result of the clickablePredicate property for the given item.
final

See Also

API
clicked, click
Gets or sets the order of the types of items that should be used to determine what item has been double-clicked or double-tapped.

Change this field to adjust which items will be considered when double-clicked if there are multiple items at a given location. The default order is

Arrays that contain strings describing the name of GraphItemTypes are converted to an array of GraphItemTypes. For example:

['node', 'edge']
['NODE', 'EDGE']
final

Examples

The following example defines the order 1. bends, 2. nodes and edges (with equal priority), 3. labels.
mode.doubleClickHitTestOrder = [
  GraphItemTypes.BEND,
  GraphItemTypes.NODE | GraphItemTypes.EDGE,
  GraphItemTypes.LABEL,
]

See Also

API
clickSelectableItems, selectableItems, findItems
Gets or sets the enabled state of this input mode.
Clients can use this property to disable or reenable this instance. This will set the enabled property of the installed controller so a disabled instance should never try to acquire the input mutex.
Gets or sets a value indicating whether this mode will be the only one running when it has the mutex.

The value of this property will be delegated to the exclusive property of the controller.

If this mode is marked as exclusive and has the mutex, all other modes added to the same MultiplexingInputMode will be deactivated. Otherwise, it will always run concurrently with all other modes.

final
Gets or sets the items that can be given focus via the setCurrentItem method.
The focusable items. The default is NODE.
conversionfinal

Examples

mode.focusableItems = GraphItemTypes.NODE | GraphItemTypes.EDGE
Gets or sets a predicate that is queried to determine whether an item should be set to the current item.
The default value returns the result of the focusableItems property for the given item. It also honors the ignoreVoidStyles property.
final

See Also

API
clicked, click
Gets the graph instance from the parentInputModeContext.
readonly

Property Value

The graph to use, which can be null.
Gets the graph selection from the parentInputModeContext.
Gets or sets the hitTester property.
The implementation will be queried by findItems to find IModelItems at a given location, e.g. if the user clicks on the canvas.
final
Gets or sets a value indicating whether void styles should be ignored when selecting or focusing items.
Void styles are styles which render their styled elements invisible. These are VOID_NODE_STYLE, VOID_EDGE_STYLE, VOID_LABEL_STYLE, and VOID_PORT_STYLE. Typically, one does not want to interact with these elements, either. The value of this property is considered by selectablePredicate and focusablePredicate. Note that even if this property is set to false the invisible elements are not selectable by mouse clicks or marquee selection since their hit testable always returns false.
final

Property Value

true if void styles should be ignored for selection and focus; false otherwise. Default is true.
Gets or sets the ItemHoverInputMode that is provided by this instance to detect when the cursor hovers over a graph item.

Note that initially the hoverItems property is set to NONE, which effectively disables the functionality of the mode initially. In order to get the mode to fire events, the property should be set to a corresponding value.

If the backing field has not yet been initialized upon first access, a new instance will be assigned. Upon change, onItemHoverInputModeChanged will be called.

By default, this input mode has a priority of 200.

final

Examples

Disabling the ItemHoverInputMode on its parent input mode
mode.itemHoverInputMode.enabled = false
The itemHoverInputMode raises the hovered-item-changed event each time cursor hovers over a different item or the canvas in which case the hovered item is null. One can also configure the item types which are reported:
Configuring the ItemHoverInputMode to handle nodes and edges
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode

// enable the ItemHoverInputMode and let it handle edges and nodes
mode.itemHoverInputMode.enabled = true
mode.itemHoverInputMode.hoverItems =
  GraphItemTypes.EDGE | GraphItemTypes.NODE
// handle changes on the hovered items
mode.itemHoverInputMode.addEventListener(
  'hovered-item-changed',
  (evt) => {
    const oldItem = evt.oldItem
    // e.g. remove the highlight from oldItem here
    const newItem = evt.item
    // e.g. add a highlight to newItem here
  },
)
Gets or sets the KeyboardInputMode associated with this instance.
By default, this input mode has a priority of 0.
final

Property Value

Examples

Disabling the KeyboardInputMode on its parent input mode
mode.keyboardInputMode.enabled = false
Adding a handler for a keyboard event
// Execute the command if the Insert key is pressed
graphEditorInputMode.keyboardInputMode.addKeyBinding(
  'Insert',
  ModifierKeys.NONE,
  () => {
    graphEditorInputMode.createNode(
      graphEditorInputMode.graphComponent!.viewport.center,
    )
  },
)
Gets or sets the LassoSelectionInputMode which handles the selection of multiple elements by drawing a polygon around them.

Upon change, the onLassoSelectionInputModeChanged method will be called.

The lassoSelectionInputMode respects the selectableItems and the marqueeSelectableItems used by marqueeSelectablePredicate.

By default, this input mode has a priority of 150 and is disabled.

final
Gets or sets which types of items should be selected during marquee selections or lasso selection.
The default is a combination of NODE, EDGE, and BEND.
conversionfinal

Examples

Determine which items should be selectable by different selection gestures
// Nodes, edges, and bends are selectable
mode.selectableItems =
  GraphItemTypes.NODE | GraphItemTypes.EDGE | GraphItemTypes.BEND
// Only nodes and bends are selectable by marquee selection
mode.marqueeSelectableItems = GraphItemTypes.NODE | GraphItemTypes.BEND
// Only nodes and edges are selectable by click selection
mode.clickSelectableItems = GraphItemTypes.NODE | GraphItemTypes.EDGE

See Also

API
marqueeSelectablePredicate, setSelected
Gets or sets a predicate that is queried to determine whether an item can be selected by marquee or lasso selection.
The default value returns the result of the marqueeSelectableItems property for the given item and takes selectablePredicate into account.
final

See Also

API
clicked, click
Gets or sets the MarqueeSelectionInputMode which handles the selection of multiple elements by drawing a rectangle around them.

Upon change, the onMarqueeSelectionInputModeChanged method will be called.

The marqueeSelectionInputMode respects the selectableItems and the marqueeSelectableItems used by marqueeSelectablePredicate.

By default, this input mode has a priority of 160.

For GraphViewerInputMode, the default values of beginRecognizer and subtractSelectionRecognizer conflict, so in this case you will usually want to change one of these recognizers.

final

Examples

Disabling the MarqueeSelectionInputMode on its parent input mode
mode.marqueeSelectionInputMode.enabled = false
Gets or sets the MoveViewportInputMode associated with this instance.

Upon change, the onMoveViewportInputModeChanged method will be called.

By default, this input mode has a priority of 190.

final

Examples

Disabling the MoveViewportInputMode on its parent input mode
mode.moveViewportInputMode.enabled = false
Gets or sets the event recognizer that determines if a click or tap is deemed a multi-selection gesture.

If the multiSelectionRecognizer returns true for the current gesture, the element which is selected with that gesture will be added to the current selection. Otherwise, the selection will be cleared before adding the newly selected element.

The default detects the current system and delegates either to META_IS_DOWN (macOS) or CTRL_IS_DOWN (other systems).

final
Gets the IInputMode that currently owns the mutex.
readonlyfinal

Property Value

The IInputMode that currently owns the mutex or null.
Gets or sets the NavigationInputMode which is responsible for navigating and traversing the elements in the IGraph.

Upon change the onNavigationInputModeChanged method will be called.

By default, this input mode has a priority of 210.

final

Examples

Disabling the NavigationInputMode on its parent input mode
mode.navigationInputMode.enabled = false

The navigationInputMode supports e.g. opening and closing group nodes. These actions can be configured in details:

// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode

// enable expanding and collapsing group nodes
mode.navigationInputMode.allowCollapseGroup = true
mode.navigationInputMode.allowExpandGroup = true
// do not fit the content after expand/collapse
mode.navigationInputMode.fitContentAfterGroupActions = false
// expand/collapse group nodes in a way that their
// top right corner stays at its current coordinates
mode.navigationInputMode.autoGroupNodeAlignmentPolicy =
  NodeAlignmentPolicy.TOP_RIGHT

It also reports when groups are opened or collapsed interactively by raising the following events:

// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.navigationInputMode.addEventListener('group-expanding', (evt) => {
  const node = evt.item
  // do something with the node before it will be expanded
})
mode.navigationInputMode.addEventListener('group-expanded', (evt) => {
  const node = evt.item
  // do something with the node after it has been expanded
})
mode.navigationInputMode.addEventListener('group-collapsing', () => {
  /* same for collapse operations */
})
mode.navigationInputMode.addEventListener('group-collapsed', () => {
  /* same for collapse operations */
})
Retrieves the IInputModeContext this mode has been installed in.
The value will be null if this mode is currently not installed. Use createInputModeContext to obtain a context that has this IInputMode as the inputMode.
protectedreadonlyfinal
Gets or sets a predicate that is queried to determine whether a context menu should be shown for an item.
The default value returns the result of the contextMenuItems property for the given item.
final

See Also

API
clicked, click
Gets the priority of this input mode.
The priority will influence the order in which the modes will be installed into the CanvasComponent. The lower the priority value, the earlier it will be installed. If two modes are using the same priority value, the first one to be registered will be installed earlier.
final
Gets or sets a predicate that is queried to determine whether a tool tip should be queried for an item.
The default value returns the result of the toolTipItems property for the given item.
final

See Also

API
query-item-tool-tip
Gets or sets which types of items should be selectable at all.
The default is ALL.
conversionfinal

Examples

Determine which items should be selectable by different selection gestures
// Nodes, edges, and bends are selectable
mode.selectableItems =
  GraphItemTypes.NODE | GraphItemTypes.EDGE | GraphItemTypes.BEND
// Only nodes and bends are selectable by marquee selection
mode.marqueeSelectableItems = GraphItemTypes.NODE | GraphItemTypes.BEND
// Only nodes and edges are selectable by click selection
mode.clickSelectableItems = GraphItemTypes.NODE | GraphItemTypes.EDGE

See Also

API
setSelected
Gets or sets a predicate that is queried to determine whether a given IModelItem is selectable.
This allows to further restrict which items are selectable, compared to selectableItems. The default value uses and honors the selectableItems and ignoreVoidStyles. This property is by default also used by clickSelectablePredicate and marqueeSelectablePredicate, so turning selection off here also turns it off in other places.
final

Examples

In the following example items are only selectable if their tag is the string "I am selectable":
mode.selectablePredicate = (item: IModelItem): boolean =>
  item.tag === 'I am selectable'
Gets or sets a value that specifies whether during hit testing, labels should be skipped at all.

Since typically users don't want to click a label when it covers a node or edge, but they typically want to click the label, but otherwise the Z-order should be considered, this setting will determine whether shouldSkipHitLabel should be queried during hit test enumeration if labels are hit before other elements.

This is only applicable when the respective clickHitTestOrder or doubleClickHitTestOrder is not explicit about the order.

This setting will influence the ILookup behavior of the IInputModeContext via childInputModeContextLookup so that the IHitTester interface swaps the order of the hits to report skipped labels only after the items behind the labels.

By default, this feature is enabled.

final
Gets or sets the toolTipInputMode which is responsible for displaying Tooltips on a CanvasComponent.

Upon change, the onToolTipInputModeChanged method will be called.

By default, this input mode has a priority of 400.

final

Examples

Disabling the ToolTipInputMode on its parent input mode
mode.toolTipInputMode.enabled = false
It is recommended to configure the tooltip handling on the parent GraphEditorInputMode or GraphViewerInputMode instead of the toolTipInputMode. This involves registering for the query-item-tool-tip event instead of the query-tool-tip event:
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.toolTipItems = GraphItemTypes.NODE
// register a listener
mode.addEventListener('query-item-tool-tip', (evt) => {
  if (evt.handled) {
    // A tooltip has already been assigned -> nothing to do.
    return
  }
  // We can safely cast here because we set ToolTipItems to only Node.
  const hitNode = evt.item as INode
  if (hitNode.labels.size > 0) {
    // Show the text of the first label as tooltip.
    evt.toolTip = hitNode.labels.get(0).text

    // Indicate that the tooltip content has been set.
    evt.handled = true
  }
})
Gets or sets the types of the items that should be queried for a tooltip.
The items for which a tooltip text should be queried. The default value is a combination of NODE, EDGE, LABEL, and PORT, i.e. everything except bends.
conversionfinal

Examples

Configuring the ToolTipInputMode to display tooltips for nodes
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.toolTipItems = GraphItemTypes.NODE
// register a listener
mode.addEventListener('query-item-tool-tip', (evt) => {
  if (evt.handled) {
    // A tooltip has already been assigned -> nothing to do.
    return
  }
  // We can safely cast here because we set ToolTipItems to only Node.
  const hitNode = evt.item as INode
  if (hitNode.labels.size > 0) {
    // Show the text of the first label as tooltip.
    evt.toolTip = hitNode.labels.get(0).text

    // Indicate that the tooltip content has been set.
    evt.handled = true
  }
})
Gets or sets the WaitInputMode that is provided by this instance for those who need to make use of it.

Upon change, the onWaitInputModeChanged method will be called.

By default, this input mode has a priority of -1.

final

Examples

Disabling the WaitInputMode on its parent input mode
mode.waitInputMode.enabled = false
Blocking user interaction during an asynchronous process
graphEditorInputMode.waiting = true
await longRunningAsyncProcess()
graphEditorInputMode.waiting = false

See Also

API
waiting

Methods

Adds the given mode.

The input modes will be ordered according to their priority: Input modes with lower priority will be installed earlier.

Input modes will run exclusively if the exclusive property of their installed controller is set to true. Otherwise they cannot and will not be deactivated if another IInputMode acquires the mutex.

final

Parameters

mode: IInputMode
The input mode to add to this mode.

Throws

Exception ({ name: 'ArgumentError' })
If the same mode is already added to this instance.

Examples

const multiplexingInputMode = new MultiplexingInputMode()
const waitInputMode = new WaitInputMode()
waitInputMode.priority = 0
multiplexingInputMode.add(waitInputMode)
const moveInputMode = new MoveViewportInputMode()
moveInputMode.priority = 5
multiplexingInputMode.add(moveInputMode)
graphComponent.inputMode = multiplexingInputMode
const mode = new GraphEditorInputMode()
const customInputMode = new CustomInputMode()
customInputMode.priority = 10
mode.add(customInputMode)
Adjusts the cursor of the CanvasComponent according to the current input mutex owner or the first mode in the list whose ConcurrencyController returns a non-null preferredCursor.
This method will set defaultCursor as the current cursor if no other preferredCursor has been specified.
Cancels all modes.
Called by the child context's lookup method.
protected

Parameters

type: Constructor
The type argument passed to lookup.

Return Value

any
The result of the lookup query, or null.
Clears the selection on the current graphSelection.
This implementation may be overridden for customizations. All it does is call clear.
Actually performs the click or tap on the given item.
This will raise the item-left-clicked, item-right-clicked (depending on the button), and item-clicked events. If either event is unhandled by all its event handlers, the item will be selected and focused. Before selection, the current selection will be cleared, unless the multiSelectionRecognizer is triggered.
protected

Parameters

item: IModelItem
The item that has been clicked.
evt: ClickEventArgs
The original event arguments for the click. Setting its handled property to true will indicate that the click was handled. By default, this happens when the clicked item is either selected or focused.
Clears the selection on click if the click is not recognized by multiSelectionRecognizer.

This method is only called if no item has been hit and at least one item is currently selected.

This will use the clearSelection method to deselect all items.

protected

Parameters

context: IInputModeContext
The context where the click appeared.

Return Value

boolean
Whether the selection has been cleared by this method.
Copies the currently selected elements to the clipboard.

Examples

mode.copy()
Yields an IInputModeContext for the child modes of this mode.
This method is called during installation to create a new context for the child modes and can be used by client code to obtain a suitable context object. The parentInputModeContext property is already set when this method is called. lookup calls for the created context will be resolved by this instance's childInputModeContextLookup method.

Return Value

IInputModeContext
A new instance that delegates to the parent's context.
Helper method that yields a suitably configured InputModeEventArgs for this input mode.
protected

Parameters

context: IInputModeContext

An input mode context that is available in the InputModeEventArgs.

Can be null in which case a new context for this instance is created automatically.

Return Value

InputModeEventArgs
An input mode event argument that is configured for this instance.
Actually performs a double-tap on the given item.
This will raise the item-left-double-clicked and item-right-double-clicked (depending on the button), and item-double-clicked events.
protected

Parameters

item: IModelItem
The item that has been double-clicked.
evt: ClickEventArgs
The original event arguments for the click. Setting its handled property to true will indicate that the double-click was handled and events on other items in the same location are no longer raised.
Used as a callback to find the items hit underneath a certain point.
This implementation uses the hitTester to determine the hit items.

Parameters

location: Point
The location to test.
tests: GraphItemTypes[]
An array of GraphItemTypes values that encode for which model items the hit test should be performed for prioritizing. Arrays that contain strings describing the name of GraphItemTypes are converted to an array of GraphItemTypes. For example:
['node', 'edge']
['NODE', 'EDGE']
filter?: function(IModelItem): boolean
The predicate that can be used to filter the results. May be null.

Return Value

IEnumerable<IModelItem>
An enumerable over the items that have been found for the location.

Examples

function HandleItemAtLocation(
  context: IInputModeContext,
  location: Point,
): void {
  const graphEditorInputMode = context.lookup(
    GraphEditorInputMode,
  ) as GraphEditorInputMode

  const graphItem = graphEditorInputMode
    .findItems(location, [GraphItemTypes.NODE | GraphItemTypes.EDGE])
    .at(0)

  if (graphItem instanceof INode) {
    // ... handle node
  } else if (graphItem instanceof IEdge) {
    // ... handle edge
  }
}
Used as a callback to find the items hit underneath a certain point.
This implementation uses the hitTester to determine the hit items and also queries the IBendSelectionTester for bends at hit edges, as well as the IPortSelectionTester for ports at hit port owners.

Parameters

context: IInputModeContext
The context to use for the isHit callback.
location: Point
The location to test.
tests: GraphItemTypes[]
An array of GraphItemTypes values that encode for which model items the hit test should be performed for prioritizing. Arrays that contain strings describing the name of GraphItemTypes are converted to an array of GraphItemTypes. For example:
['node', 'edge']
['NODE', 'EDGE']
filter?: function(IModelItem): boolean
The predicate that can be used to filter the results. May be null.

Return Value

IEnumerable<IModelItem>
An enumerable over the items that have been found for the location.

Examples

function HandleItemAtLocation(
  context: IInputModeContext,
  location: Point,
): void {
  const graphEditorInputMode = context.lookup(
    GraphEditorInputMode,
  ) as GraphEditorInputMode

  const graphItem = graphEditorInputMode
    .findItems(location, [GraphItemTypes.NODE | GraphItemTypes.EDGE])
    .at(0)

  if (graphItem instanceof INode) {
    // ... handle node
  } else if (graphItem instanceof IEdge) {
    // ... handle edge
  }
}
Returns a list of all modes managed by this instance sorted by their priority.
final

Return Value

IList<IInputMode>
A list of the modes.
Called by click to query the item for an IClickListener in its lookup and handle it appropriately.
This method will query the IClickListener and check whether it was hit by the click, and if so, will invoke onClicked and return true.
protected

Parameters

context: IInputModeContext
The context for the click.
item: IModelItem
The item that has been clicked.
location: Point
The click location.

Return Value

boolean
Whether the action has been invoked and handling should be stopped.

See Also

API
IClickListener, click
Performs one-time initialization of this instance.

This method should not be invoked by subclasses. This will be done automatically upon first installation of this mode.

This code will be executed only once per instance. The parentInputModeContext property will be null when this code is executed. This method should not be used to install this mode into a specific canvas. Subclasses should always call base.Initialize() first.

protected

See Also

API
install
Installs this mode into the given context that is provided by the canvas.

In general a mode can only be installed into a single canvas at all times.

This method is called to initialize this instance. Implement this method to register the corresponding event handlers for the various input events this mode will listen to.

When this instance gets uninstalled from the context the same context instance will be passed to it.

Implementations may hold a reference to the context instance and use it while installed.

Parameters

context: IInputModeContext
The context that this instance shall be installed into. The same instance will be passed to this instance during uninstall. A reference to the context may be kept and queried while the mode is installed.
controller: ConcurrencyController
The ConcurrencyController for this mode.
Invalidates the canvas this mode is currently installed in.
Performs lasso-selection with the given path.
It delegates directly to the onLassoSelect overload internally.
final

Parameters

lassoPath: GeneralPath
The lasso selection path.
selectionPolicy?: SelectionPolicy
The policy to use for changing the selection of the elements.
Performs marquee selection with the given rectangle.
It delegates directly to the onMarqueeSelect overload internally.
final

Parameters

marqueeRectangle: Rect
The selection rectangle.
selectionPolicy?: SelectionPolicy
The policy to use for changing the selection of the elements.
Raises the canvas-clicked event.
This implementation will stop the event propagation as soon as an event handler has set the handled property to true.
protected

Parameters

evt: ClickEventArgs
The ClickEventArgs instance that contains the information about the click.
Called when the clickInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: ClickInputMode
the old value, which may be null the first time
newMode: ClickInputMode
the new value
Called after the active property of the installed ConcurrencyController has been set to true.
This implementation reenables previously disabled concurrent child modes.
protected
Called after the active property of the installed ConcurrencyController has been set to false.
This implementation sets the preferredCursor property to null and releases the mutex if the mutex is currently owned by this instance. Also, all concurrent child modes will be disabled.
protected
Called when the ContextMenuInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: ContextMenuInputMode
the old value, which may be null the first time
newMode: ContextMenuInputMode
the new value
Raises the item-clicked event.
This implementation will stop the event propagation as soon as an event handler has set the handled property to true.
protected

Parameters

evt: ItemClickedEventArgs<IModelItem>
The ItemClickedEventArgs<T> instance that contains the item that has been clicked.
Raises the item-double-clicked event.
This implementation will stop the event propagation as soon as an event handler has set the handled property to true.
protected

Parameters

evt: ItemClickedEventArgs<IModelItem>
The ItemClickedEventArgs<T> instance that contains the item that has been double-clicked.
Called when the itemHoverInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: ItemHoverInputMode
the old value, which may be null the first time
newMode: ItemHoverInputMode
the new value
Raises the item-left-clicked event.
This implementation will stop the event propagation as soon as an event handler has set the handled property to true.
protected

Parameters

evt: ItemClickedEventArgs<IModelItem>
The ItemClickedEventArgs<T> instance that contains the item that has been clicked.
Raises the item-left-double-clicked event.
This implementation will stop the event propagation as soon as an event handler has set the handled property to true.
protected

Parameters

evt: ItemClickedEventArgs<IModelItem>
The ItemClickedEventArgs<T> instance that contains the item that has been double-clicked.
Raises the item-right-clicked event.
This implementation will stop the event propagation as soon as an event handler has set the handled property to true.
protected

Parameters

evt: ItemClickedEventArgs<IModelItem>
The ItemClickedEventArgs<T> instance that contains the item that has been clicked.
Raises the item-right-double-clicked event.
This implementation will stop the event propagation as soon as an event handler has set the handled property to true.
protected

Parameters

evt: ItemClickedEventArgs<IModelItem>
The ItemClickedEventArgs<T> instance that contains the item that has been double clicked.
Called when the keyboardInputMode changes.
Performs lasso-selection with the given path.
This method is called internally when either the lassoSelect method is called or the user performs a lasso-selection gesture via lassoSelectionInputMode.
protected

Parameters

context: IInputModeContext
The input mode context.
lassoPath: GeneralPath
The lasso selection path.
selectionPolicy: SelectionPolicy
The policy to use for changing the selection of the elements.
Called when the lassoSelectionInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: LassoSelectionInputMode
the old value, which may be null the first time
newMode: LassoSelectionInputMode
the new value
Performs marquee selection with the given rectangle.
This method is called internally when either the marqueeSelect method is called or the user performs a marquee-selection gesture via marqueeSelectionInputMode.
protected

Parameters

context: IInputModeContext
The input mode context.
marqueeRectangle: Rect
The selection rectangle.
selectionPolicy: SelectionPolicy
The policy for changing the selection.
Called when the marqueeSelectionInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: MarqueeSelectionInputMode
the old value, which may be null the first time
newMode: MarqueeSelectionInputMode
the new value
Called when the moveViewportInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: MoveViewportInputMode
the old value, which may be null the first time
newMode: MoveViewportInputMode
the new value
Raises the multi-selection-finished event.
protected

Parameters

evt: SelectionEventArgs<IModelItem>
The SelectionEventArgs<IModelItem> that provides the selection.
Raises the multi-selection-started event.
protected

Parameters

evt: SelectionEventArgs<IModelItem>
The SelectionEventArgs<IModelItem> that provides the selection.
Called when the navigationInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: NavigationInputMode
the old value, which may be null the first time
newMode: NavigationInputMode
the new value
Raises the populate-item-context-menu event.
protected

Parameters

evt: PopulateItemContextMenuEventArgs<IModelItem>
The PopulateItemContextMenuEventArgs<TModelItem> instance containing the event data.
Raises the query-item-tool-tip event.
protected

Parameters

evt: QueryItemToolTipEventArgs<IModelItem>
The QueryItemToolTipEventArgs<TModelItem> instance containing the event data.
Called when the toolTipInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: ToolTipInputMode
the old value, which may be null the first time
newMode: ToolTipInputMode
the new value
Called when the waitInputMode property value changes and after initialization of the property.
protected

Parameters

oldMode: WaitInputMode
the old value, which may be null the first time
newMode: WaitInputMode
the new value
Removes the given mode from this compound mode.
final

Parameters

mode: IInputMode
The mode to remove.
Clears the current selection and selects all nodes and bends in this graph.
By default, this method will be called in response to a Ctrl+A key press recognized by keyboardInputMode.

See Also

API
clearSelection, setSelected, SELECT_ALL, selectableItems, ignoreVoidStyles
Called by this instance to set the current item on the NavigationInputMode

Parameters

item: IModelItem
The item to set as the new "current" item.
Uses the graphSelection to select the given item.

Parameters

item: IModelItem
The item to set the selection state on.
selected: boolean
The new selection state.
Callback function that is used during hit testing, when an ILabel was hit tested before another non-label underneath it was reported.

This method can be used to prioritize the hit testing order for items below labels, depending on the label.

This implementation returns false if skipHitLabels is false or if the context's inputMode is not a GraphInputMode or MoveInputMode.

protected

Parameters

context: IInputModeContext
The context in which the hit testing is performed.
hitLabel: ILabel
The label that was hit before a non-label at the same location.
location: Point
The location the label was hit.

Return Value

boolean
Whether to first report the non-label during hit testing.
Called when the priority of an installed sub mode has changed.
This implementation uninstalls all sub modes and then re-installs them according to their new priorities.
protectedfinal
Tries to stop all modes.

Return Value

boolean
true if the editing process was successfully stopped, or if there was no edit in progress to stop; otherwise, false.
Uninstalls this mode from the given context.
This code should clean up all changes made to the canvas in the install method. After a mode has been uninstalled it can be installed again into the same or another canvas.

Parameters

context: IInputModeContext
The context to deregister from. This is the same instance that had been passed to install during installation.

Events

Occurs when the empty canvas area has been clicked or tapped.
If one of the event handlers sets the handled property to true the event will not be propagated anymore.

Properties of

ClickEventArgs
altKey: boolean
Gets a value indicating whether the alt modifier was pressed at the time of the click.
clickCount: number
Gets the number of clicks associated with this event.
context: IInputModeContext
Gets the context for the current event.
ctrlKey: boolean
Gets a value indicating whether the control modifier was pressed at the time of the click.
handled: boolean
writable
Gets or sets a value indicating whether this instance has been handled.
location: Point
Gets the location of the click.
metaKey: boolean
Gets a value indicating whether the meta modifier was pressed at the time of the click.
modifiers: ModifierKeys
Gets the state of the modifiers at the time of the click.
originalEventArgs: PointerEventArgs
Gets the pointer event args that caused this event.
pointerButtons: PointerButtons
Gets the PointerButtons that have changed for this event.
pointerType: PointerType
Gets the type of the pointer that was the source of this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier was pressed at the time of the click.

See Also

API
item-clicked
Occurs when an item has been clicked or tapped.

If one of the event handlers sets the handled property to true the event will not be propagated anymore.

Button-specific and input type specific events (item-left-clicked and item-right-clicked) will be raised before this event. If one of those is marked handled this event will not be raised anymore.

altKey: boolean
Gets a value indicating whether the alt modifier was pressed at the time of the click.
clickCount: number
Gets the number of clicks associated with this event.
context: IInputModeContext
Gets the context for the current event.
ctrlKey: boolean
Gets a value indicating whether the control modifier was pressed at the time of the click.
handled: boolean
writable
Gets or sets a value indicating whether this instance has been handled.
item: T
Gets the item that is the subject of the event.
location: Point
Gets the location of the click.
metaKey: boolean
Gets a value indicating whether the meta modifier was pressed at the time of the click.
modifiers: ModifierKeys
Gets the state of the modifiers at the time of the click.
originalEventArgs: PointerEventArgs
Gets the pointer event args that caused this event.
pointerButtons: PointerButtons
Gets the PointerButtons that have changed for this event.
pointerType: PointerType
Gets the type of the pointer that was the source of this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier was pressed at the time of the click.

Examples

mode.addEventListener('item-clicked', (evt) => {
  const node = evt.item
  if (node !== null) {
    doSomethingWithNode(node)
    evt.handled = true
  }
})

See Also

Developer's Guide
API
clickableItems, item-double-clicked, item-left-clicked, item-right-clicked
Occurs when an item has been double-clicked or double-tapped.

If one of the event handlers sets the handled property to true the event will not be propagated anymore.

Depending on the value of the clickReportingPolicy property of clickInputMode this event may be preceded by no, one, or two item-clicked events (as well as the corresponding button-specific event).

Button-specific and input-type specific events (item-left-double-clicked and item-right-double-clicked) will be raised before this event. If one of those is marked handled this event will not be raised anymore.

altKey: boolean
Gets a value indicating whether the alt modifier was pressed at the time of the click.
clickCount: number
Gets the number of clicks associated with this event.
context: IInputModeContext
Gets the context for the current event.
ctrlKey: boolean
Gets a value indicating whether the control modifier was pressed at the time of the click.
handled: boolean
writable
Gets or sets a value indicating whether this instance has been handled.
item: T
Gets the item that is the subject of the event.
location: Point
Gets the location of the click.
metaKey: boolean
Gets a value indicating whether the meta modifier was pressed at the time of the click.
modifiers: ModifierKeys
Gets the state of the modifiers at the time of the click.
originalEventArgs: PointerEventArgs
Gets the pointer event args that caused this event.
pointerButtons: PointerButtons
Gets the PointerButtons that have changed for this event.
pointerType: PointerType
Gets the type of the pointer that was the source of this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier was pressed at the time of the click.

Examples

mode.addEventListener('item-double-clicked', (evt) => {
  const node = evt.item
  if (node !== null) {
    doSomethingWithNode(node)
    evt.handled = true
  }
})

See Also

Developer's Guide
API
item-clicked, clickableItems, item-left-double-clicked, item-right-double-clicked
Occurs when an item has been left-clicked.

This event will be raised before the item-clicked event. If one of the event handlers sets the handled property to true the event will not be propagated anymore. This also means that the item-clicked event will not be raised in that case.

The term "left click" refers to a click with the left mouse button or a stylus tap.

altKey: boolean
Gets a value indicating whether the alt modifier was pressed at the time of the click.
clickCount: number
Gets the number of clicks associated with this event.
context: IInputModeContext
Gets the context for the current event.
ctrlKey: boolean
Gets a value indicating whether the control modifier was pressed at the time of the click.
handled: boolean
writable
Gets or sets a value indicating whether this instance has been handled.
item: T
Gets the item that is the subject of the event.
location: Point
Gets the location of the click.
metaKey: boolean
Gets a value indicating whether the meta modifier was pressed at the time of the click.
modifiers: ModifierKeys
Gets the state of the modifiers at the time of the click.
originalEventArgs: PointerEventArgs
Gets the pointer event args that caused this event.
pointerButtons: PointerButtons
Gets the PointerButtons that have changed for this event.
pointerType: PointerType
Gets the type of the pointer that was the source of this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier was pressed at the time of the click.

Examples

mode.addEventListener('item-left-clicked', (evt) => {
  const node = evt.item
  if (node !== null) {
    doSomethingWithNode(node)
    evt.handled = true
  }
})

See Also

API
clickableItems, item-double-clicked, item-clicked, item-right-clicked, item-left-double-clicked
Occurs when an item has been left double-clicked.
This event will be raised before the item-double-clicked event. If one of the event handlers sets the handled property to true the event will not be propagated anymore. This also means that the item-double-clicked event will not be raised in that case.
altKey: boolean
Gets a value indicating whether the alt modifier was pressed at the time of the click.
clickCount: number
Gets the number of clicks associated with this event.
context: IInputModeContext
Gets the context for the current event.
ctrlKey: boolean
Gets a value indicating whether the control modifier was pressed at the time of the click.
handled: boolean
writable
Gets or sets a value indicating whether this instance has been handled.
item: T
Gets the item that is the subject of the event.
location: Point
Gets the location of the click.
metaKey: boolean
Gets a value indicating whether the meta modifier was pressed at the time of the click.
modifiers: ModifierKeys
Gets the state of the modifiers at the time of the click.
originalEventArgs: PointerEventArgs
Gets the pointer event args that caused this event.
pointerButtons: PointerButtons
Gets the PointerButtons that have changed for this event.
pointerType: PointerType
Gets the type of the pointer that was the source of this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier was pressed at the time of the click.

Examples

mode.addEventListener('item-left-double-clicked', (evt) => {
  const node = evt.item
  if (node !== null) {
    doSomethingWithNode(node)
    evt.handled = true
  }
})

See Also

API
clickableItems, item-double-clicked, item-right-double-clicked
Occurs when an item has been right-clicked.
This event will be raised before the item-clicked event. If one of the event handlers sets the handled property to true the event will not be propagated anymore. This also means that the item-clicked event will not be raised in that case.
altKey: boolean
Gets a value indicating whether the alt modifier was pressed at the time of the click.
clickCount: number
Gets the number of clicks associated with this event.
context: IInputModeContext
Gets the context for the current event.
ctrlKey: boolean
Gets a value indicating whether the control modifier was pressed at the time of the click.
handled: boolean
writable
Gets or sets a value indicating whether this instance has been handled.
item: T
Gets the item that is the subject of the event.
location: Point
Gets the location of the click.
metaKey: boolean
Gets a value indicating whether the meta modifier was pressed at the time of the click.
modifiers: ModifierKeys
Gets the state of the modifiers at the time of the click.
originalEventArgs: PointerEventArgs
Gets the pointer event args that caused this event.
pointerButtons: PointerButtons
Gets the PointerButtons that have changed for this event.
pointerType: PointerType
Gets the type of the pointer that was the source of this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier was pressed at the time of the click.

Examples

mode.addEventListener('item-right-clicked', (evt) => {
  const node = evt.item
  if (node !== null) {
    doSomethingWithNode(node)
    evt.handled = true
  }
})

See Also

API
clickableItems, item-double-clicked, item-clicked, item-left-clicked, item-right-double-clicked
Occurs when an item has been right double-clicked.
This event will be raised before the item-double-clicked event. If one of the event handlers sets the handled property to true the event will not be propagated anymore. This also means that the item-double-clicked event will not be raised in that case.
altKey: boolean
Gets a value indicating whether the alt modifier was pressed at the time of the click.
clickCount: number
Gets the number of clicks associated with this event.
context: IInputModeContext
Gets the context for the current event.
ctrlKey: boolean
Gets a value indicating whether the control modifier was pressed at the time of the click.
handled: boolean
writable
Gets or sets a value indicating whether this instance has been handled.
item: T
Gets the item that is the subject of the event.
location: Point
Gets the location of the click.
metaKey: boolean
Gets a value indicating whether the meta modifier was pressed at the time of the click.
modifiers: ModifierKeys
Gets the state of the modifiers at the time of the click.
originalEventArgs: PointerEventArgs
Gets the pointer event args that caused this event.
pointerButtons: PointerButtons
Gets the PointerButtons that have changed for this event.
pointerType: PointerType
Gets the type of the pointer that was the source of this event.
shiftKey: boolean
Gets a value indicating whether the shift modifier was pressed at the time of the click.

Examples

mode.addEventListener('item-right-double-clicked', (evt) => {
  const node = evt.item
  if (node !== null) {
    doSomethingWithNode(node)
    evt.handled = true
  }
})

See Also

API
clickableItems, item-double-clicked, item-left-double-clicked
Occurs when the copy operation finished successfully.
The items in the ItemsEventArgs are the original items in graph that were copied during the copy operation.

Properties of

ItemsEventArgs
context: IInputModeContext
Gets the context for the current event.
items: IListEnumerable<IModelItem>
Gets the items that are the subjects for this event.

See Also

Developer's Guide
Occurs when a single or multi select operation has been finished.
The event is not triggered for the individual selection operations that constitute a multi selection operation.
context: IInputModeContext
Gets the context for the current event.
selection: IObservableCollection<T>
Gets the selection these event arguments refer to.
Occurs when a single or multi select operation has been started.
The event is not triggered for the individual selection operations that constitute a multi selection operation.
context: IInputModeContext
Gets the context for the current event.
selection: IObservableCollection<T>
Gets the selection these event arguments refer to.
Occurs when the context menu over an item is about to be opened to determine the contents of the context menu.
This method will only be called for items that match the contextMenuItems type.
context: IInputModeContext
Gets the context for the current event.
contextMenu: ContextMenuContent
writable
Gets or sets the context menu content to use.
handled: boolean
writable
Gets or sets a value indicating whether this PopulateContextMenuEventArgs has been handled.
item: TModelItem
Gets the item for which the context menu is queried.
queryLocation: Point
Gets the queried location in world coordinates.
showMenu: boolean
writable
Gets or sets a value indicating whether to actually display the context menu.

Examples

// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.contextMenuItems = GraphItemTypes.NODE
mode.addEventListener('populate-item-context-menu', (evt) => {
  // Get the node which is handled or null if the item is not a node
  const node = evt.item
  // Create the context menu items
  if (node !== null) {
    // Create a menu item to delete the node

    // Show the menu
    evt.contextMenu = [
      { label: 'Delete Item', action: () => graph.remove(node) },
    ]
  }
})
Occurs when the mouse is hovering over an item to determine the tool tip to display.
This method will only be called for items that match the toolTipItems type.
context: IInputModeContext
Gets the context for the current event.
handled: boolean
writable
Gets or sets a value indicating whether this QueryToolTipEventArgs has been handled.
item: TModelItem
Gets the item for which the tool tip is queried.
queryLocation: Point
Gets the query location in world coordinates.
toolTip: any
writable
Gets or sets the tooltip content to use.
toolTipAsync: Promise<any>
writable
Gets or sets a Promise<T> that provides the tooltip content to use.

Examples

Configuring the ToolTipInputMode to display tooltips for nodes
// mode is either an instance of GraphEditorInputMode or GraphViewerInputMode
mode.toolTipItems = GraphItemTypes.NODE
// register a listener
mode.addEventListener('query-item-tool-tip', (evt) => {
  if (evt.handled) {
    // A tooltip has already been assigned -> nothing to do.
    return
  }
  // We can safely cast here because we set ToolTipItems to only Node.
  const hitNode = evt.item as INode
  if (hitNode.labels.size > 0) {
    // Show the text of the first label as tooltip.
    evt.toolTip = hitNode.labels.get(0).text

    // Indicate that the tooltip content has been set.
    evt.handled = true
  }
})