CommandHandler class

The Diagram#commandHandler implements various commands such as CommandHandler#deleteSelection or CommandHandler#redo. The CommandHandler includes keyboard event handling to interpret key presses as commands.

CommandHandlers cannot be shared amongst multiple Diagrams.

You may define a CommandHandler subclass and override methods. However you must seriously consider calling the base method in order to get its default behavior. There may be situations where not calling the base method may cause subtle bugs, but that depends on the method. Please read the Introduction page on Extensions for how to override methods and how to call a base method.

There is an example custom CommandHandler in the extensions directory: DrawCommandHandler.js, which provides alignment commands and additional behaviors for the arrow keys.

For additional discussion, please read the Introduction page on Commands.

Keyboard Shortcuts

The CommandHandler implements the following command bindings for keyboard input in #doKeyDown:

  • Ctrl-X & Shift-Del invoke #cutSelection
  • Ctrl-C & Ctrl-Insert invoke #copySelection
  • Ctrl-V & Shift-Insert invoke #pasteSelection
  • Del & Backspace invoke #deleteSelection
  • Ctrl-A invokes #selectAll
  • Ctrl-Z & Alt-Backspace invoke #undo
  • Ctrl-Y & Alt-Shift-Backspace invoke #redo
  • Up & Down & Left & Right (arrow keys) call Diagram#scroll
  • PageUp & PageDown call Diagram#scroll
  • Home & End call Diagram#scroll
  • Space invokes #scrollToPart
  • Ctrl-- & Keypad-- (minus) invoke #decreaseZoom
  • Ctrl-+ & Keypad-+ (plus) invoke #increaseZoom
  • Ctrl-0 invokes #resetZoom
  • Shift-Z invokes #zoomToFit; repeat to return to the original scale and position
  • Ctrl-G invokes #groupSelection
  • Ctrl-Shift-G invokes #ungroupSelection
  • F2 invokes #editTextBlock
  • Menu Key invokes #showContextMenu
  • Esc invokes #stopCommand

On a Macintosh the Command key is used as the modifier instead of the Control key.

On touch devices there is a default context menu that shows many commonly-used commands when you hold a finger down on the diagram.

Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

CommandHandler()
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited