Options
All
  • Public
  • Public/Protected
  • All
Menu

An InputTrigger listens to keyboard events and to DOM changes that insert text into an element. The object has to listen to both types of events because:

  • Listening only to keyboard events would miss modifications to the DOM tree that happen programmatically.

  • Listening only to DOM changes would not trap keyboard events that do not inherently modify the DOM tree like a backspace key hit at the start of an element.

The portion of InputTrigger objects that handle keyboard events attaches itself to the editor to which the InputTrigger belongs in such a way that allows for suppressing the generic handling of such events. See addKeyHandler for more information.

Hierarchy

  • InputTrigger

Index

Constructors

constructor

Properties

Private editor

editor: EditorAPI

The editor to which this InputTrigger belongs.

Private keyToHandler

keyToHandler: Map<Key, KeyHandler[]> = new Map()

Private mode

mode: Mode

The mode for which this InputTrigger is being created.

Private selector

selector: GUISelector

This is a CSS selector which must be fit to be used in the GUI tree. (For instance by being the output of "wed/domutil".toGUISelector.)

Private textInputKeyToHandler

textInputKeyToHandler: Map<Key, KeyHandler[]> = new Map()

Methods

addKeyHandler

  • Adds a key handler to the object.

    The handler is called once per event. This means for instance that if a paste event introduces the text "a;b;c" and we are listening for ";", the handler will be called once, even though two ";" are added. It is up to the handler to detect that ";" has been added more than once.

    Handlers that wish to stop further processing or prevent the browser's default processing of an event must call the appropriate method on the event object.

    Although it is possible to add multiple handlers for the same key to the same InputTrigger object, the InputTrigger class does not define how one handler could prevent another handler from executing. Calling the methods on the event object does not in any way affect how an InputTrigger calls its handlers. However, as stated above, these methods can prevent further propagation of the JavaScript event. Consequently, if more than one handler should handle the same key on the same InputTrigger object, these handlers should either deal with orthogonal concerns (e.g. one modifies the data DOM tree and the other does logging), or provide their own mechanism to determine whether one can prevent the other from executing.

    Parameters

    • key: Key

      The key we are interested in.

    • handler: KeyHandler

      The handler that will process events related to that key.

    Returns void

Private getNodeOfInterest

  • getNodeOfInterest(): Element | null

Private keydownHandler

  • keydownHandler(_wedEvent: Event, e: JQueryKeyEventObject): void
  • Handles keydown events.

    Parameters

    • _wedEvent: Event

      The DOM event wed generated to trigger this handler.

    • e: JQueryKeyEventObject

      The original DOM event that wed received.

    Returns void

Private keypressHandler

  • keypressHandler(_wedEvent: Event, e: JQueryKeyEventObject): void
  • Handles keypress events.

    Parameters

    • _wedEvent: Event

      The DOM event wed generated to trigger this handler.

    • e: JQueryKeyEventObject

      The original DOM event that wed received.

    Returns void

Private pasteHandler

  • pasteHandler(_wedEvent: Event, e: JQueryKeyEventObject, caret: DLoc, data: Element): void
  • Handles paste events.

    Parameters

    • _wedEvent: Event

      The DOM event wed generated to trigger this handler.

    • e: JQueryKeyEventObject

      The original DOM event that wed received.

    • caret: DLoc

      The data caret.

    • data: Element

      The data that the user wants to insert.

    Returns void

Generated using TypeDoc