Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DrawCommandHandler Extension

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. Extensions can be found in the GoJS kit under the extensions (for loading via script tags),extensionsTS (UMD modules), or extensionsJSM (ES6 modules) folders. See the Extensions intro page for more information.

Hierarchy

This CommandHandler class allows the user to position selected Parts in a diagram relative to the first part selected, in addition to overriding the doKeyDown method of the CommandHandler for handling the arrow keys in additional manners.

Typical usage:

  $(go.Diagram, "myDiagramDiv",
{
commandHandler: $(DrawCommandHandler),
. . .
}
)

or:

   myDiagram.commandHandler = new DrawCommandHandler();

If you want to experiment with this extension, try the Drawing Commands sample.

Index

Inherited Members

Properties

Methods

Constructors

  • The constructor produces a CommandHandler with the default key bindings.

    Returns DrawCommandHandler

Properties

  • Gets or sets the arrow key behavior. Possible values are "move", "select", and "scroll".

    The default value is "move".

  • Gets or sets the offset at which each repeated pasteSelection puts the new copied parts from the clipboard.

Methods

  • alignBottom(): void
  • Aligns selected parts at the bottom-most edge of the bottom-most part.

    Returns void

  • alignCenterX(): void
  • Aligns selected parts at the x-value of the center point of the first selected part.

    Returns void

  • alignCenterY(): void
  • Aligns selected parts at the y-value of the center point of the first selected part.

    Returns void

  • alignColumn(distance: number): void
  • Aligns selected parts top-to-bottom in order of the order selected. Distance between parts can be specified. Default distance is 0.

    Parameters

    • distance: number

    Returns void

  • alignLeft(): void
  • Aligns selected parts along the left-most edge of the left-most part.

    Returns void

  • alignRight(): void
  • Aligns selected parts at the right-most edge of the right-most part.

    Returns void

  • alignRow(distance: number): void
  • Aligns selected parts left-to-right in order of the order selected. Distance between parts can be specified. Default distance is 0.

    Parameters

    • distance: number

    Returns void

  • alignTop(): void
  • Aligns selected parts at the top-most edge of the top-most part.

    Returns void

  • canAlignSelection(): boolean
  • canRotate(): boolean
  • This controls whether or not the user can invoke the rotate command.

    Returns boolean

    This returns true: if the diagram is not Diagram.isReadOnly, if the model is not Model.isReadOnly, and if there is at least one selected Part.

  • Reset the last offset for pasting.

    Parameters

    Returns void

  • doKeyDown(): void
  • This implements custom behaviors for arrow key keyboard events. Set arrowKeyBehavior to "select", "move" (the default), "scroll" (the standard behavior), or "none" to affect the behavior when the user types an arrow key.

    Returns void

  • Paste from the clipboard with an offset incremented on each paste, and reset when copied.

    Returns Set<Part>

    a collection of newly pasted Parts

  • pullToFront(): void
  • Change the z-ordering of selected parts to pull them forward, in front of all other parts in their respective layers. All unselected parts in each layer with a selected Part with a non-numeric Part.zOrder will get a zOrder of zero.

    Returns void

  • pushToBack(): void
  • Change the z-ordering of selected parts to push them backward, behind of all other parts in their respective layers. All unselected parts in each layer with a selected Part with a non-numeric Part.zOrder will get a zOrder of zero.

    Returns void

  • rotate(angle: number): void
  • Change the angle of the parts connected with the given part. This is in the command handler so it can be easily accessed for the purpose of creating commands that change the rotation of a part.

    Parameters

    • angle: number

      the positive (clockwise) or negative (counter-clockwise) change in the rotation angle of each Part, in degrees.

    Returns void