Nodify-docs
Nodify.Avalonia — Editor gestures

Editor gestures

Nodify.Avalonia routes built-in interactions through InputProcessor. Gesture mappings are grouped in EditorGestures and can be supplied per editor, so one application can host editors with different input schemes.

Default gestures

Editor

ActionDefault input
PanRight-button drag or middle-button drag
ZoomPointer wheel
Zoom inCtrl++ or Ctrl+numpad +
Zoom outCtrl+- or Ctrl+numpad -
Select areaLeft-button drag
Add to selectionShift+left-button drag
Remove from selectionAlt+left-button drag
Invert selectionCtrl+left-button drag
Select allCtrl+A
Push itemsCtrl+Shift+left-button drag
Cut connectionsAlt+Shift+left-button drag
Reset viewportHome
Fit items to viewportShift+Home
Cancel the active operationRight click or Escape

Item containers

Left click selects and drags an item. Add Shift, Alt, or Ctrl to append, remove, or invert its selection. Right click or Escape cancels a drag when cancellation is enabled.

Connectors and connections

ActionDefault input
Start or complete a pending connectionLeft click or Space on a connector
Cancel a pending connectionRight click or Escape
Disconnect all links from a connectorAlt+left click or Delete
Select a connectionLeft click
Add a connection to selectionShift+left click
Remove a connection from selectionAlt+left click
Invert a connection’s selectionCtrl+left click
Split a connectionLeft double-click
Remove a connectionAlt+left click

Grouping nodes

Hold Shift while dragging a grouping node by its header to switch its movement mode for that drag. When the grouping node is selected and focused, Ctrl+Space or Ctrl+Enter toggles the selection state of its content.

Minimap

ActionDefault input
Move the viewportLeft-button drag
PanArrow keys
ZoomPointer wheel
Zoom inCtrl++ or Ctrl+numpad +
Zoom outCtrl+- or Ctrl+numpad -
Reset viewportHome
Cancel panningRight click or Escape

Keyboard navigation

ActionDefault input
Move focusArrow keys
Toggle focused selectionSpace or Enter
Move selected itemsCtrl+arrow keys
PanHold Space, then press an arrow key
Clear selectionEscape
Next navigation layerCtrl+]
Previous navigation layerCtrl+[

These defaults come from the matching groups on EditorGestures: Editor, ItemContainer, Connector, Connection, GroupingNode, and Minimap.

Per-editor gesture mappings

Create a new mapping rather than modifying the global EditorGestures.Mappings singleton:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
using Avalonia.Input;
using Nodify.Avalonia;
using Nodify.Avalonia.Helpers.Gestures;

public EditorGestures Gestures { get; } = CreateGestures();

private static EditorGestures CreateGestures()
{
    var gestures = new EditorGestures();
    gestures.Editor.ZoomModifierKey = KeyModifiers.Control;
    gestures.Editor.PanWithMouseWheel = true;
    gestures.Editor.PanHorizontalModifierKey = KeyModifiers.Shift;
    return gestures;
}

Bind the mapping to one editor:

1
<nodify:NodifyEditor InputGestures="{Binding Gestures}" />

ActualGestures returns the per-editor mapping when InputGestures is set and the global mapping otherwise.

Disable a gesture

Every InputGestureRef can be unbound. For example, disable connection cutting and area selection in a read-only editor:

1
2
3
var gestures = new EditorGestures();
gestures.Editor.Cutting.Unbind();
gestures.Editor.Selection.Unbind();

Use Unbind() on a gesture group to disable all gestures in that group. Disabling a gesture does not disable the corresponding public methods or routed commands.

Toggled interactions

The default drag interactions start on pointer press and finish on release. These static switches allow the same gesture to start and stop an operation instead:

1
2
3
4
NodifyEditor.EnableToggledPanningMode = true;
NodifyEditor.EnableToggledSelectingMode = true;
NodifyEditor.EnableToggledPushingItemsMode = true;
NodifyEditor.EnableToggledCuttingMode = true;

These settings affect every editor in the process. Set them once during application startup.

Keyboard navigation

The editor always registers the nodes layer and registers the connections layer by default. Set the static NodifyEditor.AutoRegisterDecoratorsLayer property to true before creating editors to register the decorators layer automatically. Only one registered layer is active at a time. Arrow keys move focus within that layer; Ctrl+[ and Ctrl+] switch layers.

The editor exposes ActiveNavigationLayer, ActivateNextNavigationLayer(), ActivatePreviousNavigationLayer(), and ActivateNavigationLayer(...) for applications that need explicit control. The static AutoFocusFirstElement property controls whether activating a layer focuses its first element.

Keyboard dragging raises the same movement events and updates the same location bindings as a pointer drag. The static MinimumNavigationStepSize and PanViewportOnKeyboardDrag properties control keyboard movement behavior for every editor.

Documentation index · Editor