GoJS API
/ to search
    Preparing search index...

    Class Robot

    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. See the Extensions intro page for more information.

    Deprecated in 4.0. Consider using Diagram.emitMouseDown and related emit... methods instead.

    A class for simulating mouse and keyboard input.

    As a special feature, this supports limited simulation of drag-and-drop between Diagrams, by setting both the sourceDiagram and targetDiagram properties on the eventprops argument of the mouseDown/mouseMove/mouseUp methods. Although go.InputEvent.targetDiagram is a real property, the sourceDiagram property is only used by these Robot methods.

    Typical setup:

       // a shared Robot that can be used by all commands for this one Diagram
    myRobot = new Robot(myDiagram); // defined in Robot.js

    Then later:

       // Simulate a mouse drag to move a node:
    const loc = ...; // some Point in document coordinates that is within the bounds of a node
    const options = {}; // possible settings of InputEvent, such as setting control or shift to true
    myRobot.mouseDown(loc.x, loc.y, 0, options);
    myRobot.mouseMove(loc.x + 80, loc.y + 50, 50, options);
    myRobot.mouseMove(loc.x + 20, loc.y + 100, 100, options);
    myRobot.mouseUp(loc.x + 20, loc.y + 100, 150, options);

    As of version 3.2, the functionality is built into the Diagram class using methods whose names start with "emit...". However, the functionality is duplicated here for compatibility with versions earlier than 3.2.

    deprecated

    See Diagram.emitMouseDown and related emit... methods

    Index

    Constructors

    Accessors

    Methods

    • Simulate a key down event.

      Parameters

      • keyCodeOrKey: string | number

        A simulated KeyboardEvent.keyCode (number) or KeyboardEvent.key (string)

      • Optionaltime: number

        the timestamp of the simulated event, in milliseconds; default zero

      • Optionaleventprops: Partial<InputEvent>

        an optional argument providing properties for the InputEvent.

      Returns void

    • Simulate a key up event.

      Parameters

      • keyCodeOrKey: string | number

        A simulated KeyboardEvent.keyCode (number) or KeyboardEvent.key (string)

      • Optionaltime: number

        the timestamp of the simulated event, in milliseconds; default zero

      • Optionaleventprops: Partial<InputEvent>

        an optional argument providing properties for the InputEvent.

      Returns void

    • Simulate a mouse down event.

      Parameters

      • x: number

        the X-coordinate of the mouse point in document coordinates.

      • y: number

        the Y-coordinate of the mouse point in document coordinates.

      • Optionaltime: number

        the timestamp of the simulated event, in milliseconds; default zero

      • Optionaleventprops: Partial<InputEvent & { sourceDiagram: Diagram }>

        an optional argument providing properties for the InputEvent.

      Returns void

    • Simulate a mouse move event.

      Parameters

      • x: number

        the X-coordinate of the mouse point in document coordinates.

      • y: number

        the Y-coordinate of the mouse point in document coordinates.

      • Optionaltime: number

        the timestamp of the simulated event, in milliseconds; default zero

      • Optionaleventprops: Partial<InputEvent & { sourceDiagram: Diagram }>

        an optional argument providing properties for the InputEvent.

      Returns void

    • Simulate a mouse up event.

      Parameters

      • x: number

        the X-coordinate of the mouse point in document coordinates.

      • y: number

        the Y-coordinate of the mouse point in document coordinates.

      • Optionaltime: number

        the timestamp of the simulated event, in milliseconds; default zero

      • Optionaleventprops: Partial<InputEvent & { sourceDiagram: Diagram }>

        an optional argument providing properties for the InputEvent.

      Returns void

    • Simulate a mouse wheel event.

      Parameters

      • delta: number

        non-zero turn

      • Optionaltime: number

        the timestamp of the simulated event, in milliseconds; default zero

      • Optionaleventprops: Partial<InputEvent>

        an optional argument providing properties for the InputEvent.

      Returns void