Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • mxKeyHandler

Index

Constructors

constructor

  • Constructs an event handler that executes functions bound to specific keystrokes.

    author

    鸿则 hungtcs@163.com

    date

    2020-01-09

    Parameters

    • graph: mxGraph

      Reference to the associated mxGraph.

    • Optional target: EventTarget

      Optional reference to the event target. If null, the document element is used as the event target, that is, the object where the key event listener is installed.

    Returns mxKeyHandler

Properties

controlKeys

controlKeys: [(event: KeyboardEvent) => void]

Maps from keycodes to functions for pressed control keys.

controlShiftKeys

controlShiftKeys: [(event: KeyboardEvent) => void]

Maps from keycodes to functions for pressed control and shift keys.

enabled

enabled: boolean

Specifies if events are handled. Default is true.

graph

graph: mxGraph

Reference to the mxGraph associated with this handler.

normalKeys

normalKeys: [(event: KeyboardEvent) => void]

Maps from keycodes to functions for non-pressed control keys.

shiftKeys

shiftKeys: [(event: KeyboardEvent) => void]

Maps from keycodes to functions for pressed shift keys.

target

target: EventTarget

Reference to the target DOM, that is, the DOM node where the key event listeners are installed.

Methods

bindControlKey

  • bindControlKey(code: number, funct: (event: KeyboardEvent) => void): void
  • Binds the specified keycode to the given function. This binding is used if the control key is pressed.

    Parameters

    • code: number
    • funct: (event: KeyboardEvent) => void
        • (event: KeyboardEvent): void
        • Parameters

          • event: KeyboardEvent

          Returns void

    Returns void

bindControlShiftKey

  • bindControlShiftKey(code: number, funct: (event: KeyboardEvent) => void): number
  • Binds the specified keycode to the given function. This binding is used if the control and shift key are pressed.

    Parameters

    • code: number
    • funct: (event: KeyboardEvent) => void
        • (event: KeyboardEvent): void
        • Parameters

          • event: KeyboardEvent

          Returns void

    Returns number

bindKey

  • bindKey(code: number, funct: (event: KeyboardEvent) => void): void
  • Binds the specified keycode to the given function. This binding is used if the control key is not pressed.

    Parameters

    • code: number
    • funct: (event: KeyboardEvent) => void
        • (event: KeyboardEvent): void
        • Parameters

          • event: KeyboardEvent

          Returns void

    Returns void

bindShiftKey

  • bindShiftKey(code: number, funct: (event: KeyboardEvent) => void): void
  • Binds the specified keycode to the given function. This binding is used if the shift key is pressed.

    Parameters

    • code: number
    • funct: (event: KeyboardEvent) => void
        • (event: KeyboardEvent): void
        • Parameters

          • event: KeyboardEvent

          Returns void

    Returns void

destroy

  • destroy(): void
  • Destroys the handler and all its references into the DOM. This does normally not need to be called, it is called automatically when the window unloads (in IE).

    Returns void

escape

  • escape(evt: KeyboardEvent): void
  • Hook to process ESCAPE keystrokes. This implementation invokes mxGraph.stopEditing to cancel the current editing, connecting and/or other ongoing modifications.

    Parameters

    • evt: KeyboardEvent

    Returns void

getFunction

  • getFunction(evt: KeyboardEvent): (event: KeyboardEvent) => void
  • Returns the function associated with the given key event or null if no function is associated with the given event.

    Parameters

    • evt: KeyboardEvent

    Returns (event: KeyboardEvent) => void

      • (event: KeyboardEvent): void
      • Parameters

        • event: KeyboardEvent

        Returns void

isControlDown

  • isControlDown(evt: KeyboardEvent): boolean
  • Returns true if the control key is pressed. This uses mxEvent.isControlDown.

    Parameters

    • evt: KeyboardEvent

    Returns boolean

isEnabled

  • isEnabled(): boolean

isEnabledForEvent

  • isEnabledForEvent(evt: KeyboardEvent): boolean
  • Returns true if the given event should be handled. isEventIgnored is called later if the event is not an escape key stroke, in which case escape is called. This implementation returns true if isEnabled returns true for both, this handler and graph, if the event is not consumed and if isGraphEvent returns true.

    Parameters

    • evt: KeyboardEvent

    Returns boolean

isEventIgnored

  • isEventIgnored(evt: KeyboardEvent): boolean
  • Returns true if the given keystroke should be ignored. This returns graph.isEditing().

    Parameters

    • evt: KeyboardEvent

    Returns boolean

isGraphEvent

  • isGraphEvent(evt: KeyboardEvent): boolean
  • Returns true if the event should be processed by this handler, that is, if the event source is either the target, one of its direct children, a descendant of the <mxGraph.container>, or the mxGraph.cellEditor of the graph.

    Parameters

    • evt: KeyboardEvent

    Returns boolean

keyDown

  • keyDown(evt: KeyboardEvent): boolean
  • Handles the event by invoking the function bound to the respective keystroke if isEnabledForEvent returns true for the given event and if isEventIgnored returns false, except for escape for which isEventIgnored is not invoked.

    Parameters

    • evt: KeyboardEvent

    Returns boolean

setEnabled

  • setEnabled(enabled: boolean): void

Generated using TypeDoc