documentationfor yFiles for HTML 2.6

GraphEditorInputMode

A complex IInputMode that can be used in a GraphComponent to edit an IGraph instance.

Inheritance Hierarchy
Implemented Interfaces

Remarks

This class delegates most of the work to minor IInputMode implementations. However it contains a number of properties that influence the general behavior:

By default, GraphEditorInputMode supports the following commands. Most of them have default keybindings:

All commands can also be selectively disabled by using the availableCommands collection. Furthermore, there are a few commands provided by navigationInputMode:

GraphEditorInputMode can be configured to automatically adjust the content rectangle of the graphComponent whenever the graph is changed using gestures.

This class contains a number of public methods that can be used to programmatically perform the corresponding actions, too.

Setting the nodeCreator to another instance or null changes the way nodes are created. Also the various minor IInputMode instances can be disabled, to change the behavior, too.

This input mode manages a set of specialized input modes, each handling a specific part of the interaction with the graph. The following list details those along with their default priorities. Lower priorities come earlier when handling events.

To enable single selection mode, disable MarqueeSelectionInputMode and set multiSelectionRecognizer to NEVER. Remove SELECT_ALL and TOGGLE_ITEM_SELECTION from availableCommands and from navigationInputMode.availableCommands. An example can be found in the Single Selection Demo.

Examples

The GraphEditorInputMode can be installed by setting it as inputMode on the graphComponent it handles.

Installing a configured GraphEditorInputMode
graphComponent.inputMode = new GraphEditorInputMode({
  allowGroupingOperations: true,
  snapContext: new GraphSnapContext(),
  labelSnapContext: new LabelSnapContext(),
  orthogonalEdgeEditingContext: new OrthogonalEdgeEditingContext({
    enabled: false
  })
})

Note that the GraphEditorInputMode also supports grouping operations. This functionality, however, is disabled by default and has to be enabled. The following example shows how to enable grouping operations on the GraphEditorInputMode together with some detail settings:

Configuring grouping operations
// first and foremost: enable grouping operations at all
geim.allowGroupingOperations = true
// support grouping but not ungrouping the currently selected nodes
geim.allowGroupSelection = true
geim.allowUngroupSelection = false
// forbid adjusting the size with Ctrl-Shift-G
geim.allowAdjustGroupNodeSize = false
// allow adding nodes to other group nodes by moving
geim.allowReparentNodes = true
// also allow to add nodes to non-group nodes, transforming these into groups
geim.allowReparentToNonGroupNodes = true
// support navigation like opening and closing groups
geim.navigationInputMode.allowExpandGroup = true
geim.navigationInputMode.allowCollapseGroup = true
// forbid entering and exiting groups
geim.navigationInputMode.allowEnterGroup = false
geim.navigationInputMode.allowExitGroup = false

Selecting multiple items is supported by default. Enabling selection for only one or no selected item at once is described in the Developer's Guide and shown in the following example:

// disable marquee and lasso selection
geim.marqueeSelectionInputMode.enabled = false
geim.lassoSelectionInputMode.enabled = false
// disable multi selection with Ctrl-Click
geim.multiSelectionRecognizer = EventRecognizers.NEVER

// deactivate commands that can lead to multi selection
geim.availableCommands.remove(ICommand.TOGGLE_ITEM_SELECTION)
geim.availableCommands.remove(ICommand.SELECT_ALL)

geim.navigationInputMode.availableCommands.remove(
  ICommand.EXTEND_SELECTION_LEFT
)
geim.navigationInputMode.availableCommands.remove(
  ICommand.EXTEND_SELECTION_UP
)
geim.navigationInputMode.availableCommands.remove(
  ICommand.EXTEND_SELECTION_DOWN
)
geim.navigationInputMode.availableCommands.remove(
  ICommand.EXTEND_SELECTION_RIGHT
)

// disable selection of (possibly multiple) items
mode.pasteSelectableItems = GraphItemTypes.NONE

Related Reading in the Developer's Guide

An overview of this input mode is given in the section Editing Graphs. Additionally, specific support for graph hierarchies is discussed in Supported User Interactions: Grouping.

Related Programming Samples

Events Viewer
Shows the multitude of events provided by the classes IGraph, GraphComponent, and the Input Modes.
Graph Editor
Shows the graph editing features of the graph component.
Single Selection
Shows how to configure GraphEditorInputMode for single selection mode.
06 Basic Interaction
Shows the default interaction gestures that are provided by class GraphEditorInputMode.

Type Details

yfiles module
view-editor
yfiles-umd modules
view-editor, view-table, view
Legacy UMD name
yfiles.input.GraphEditorInputMode

See Also

Constructors

Properties

Methods

Events

Constants