Skip to content

InputTrigger syntax

tpietzsch edited this page Dec 16, 2016 · 6 revisions

Overview

ui-behaviour is a library for binding behaviours by keys or mouse-actions. The idea is similar to Swing's InputMap/ActionMap framework. The difference is that actions are atomic while behaviours (possibly) stretch over a period of time. For example, a DragBehaviour is initialized (e.g., with a mouse click) at certain coordinates, goes through a series of coordinate updates, and then ends (when the mouse is released).

The combination of modifiers, keys, mouse buttons etc. that initiates a behaviour is called a "trigger" and is constructed from a string description.

The basic syntax for a trigger description is a sequence of modifier and key names separated by whitespace. Examples are SPACE, button1, shift alt scroll, and ctrl F G.

Additionally, one can specify a combination of modifiers, keys, mouse buttons etc. that should be ignored when triggering the behaviour. This is a another sequence of modifier and key names separated from the trigger description by "|". For example, ctrl button1 | shift alt is triggered by pressing the left mouse-button while holding the ctrl key. If the shift and/or alt key are pressed simultaneously, the trigger still matches. To ignore all other modifiers and keys, the special name all is used. So, A | all is a trigger that matches when the A key is pressed, regardless which other modifiers, keys, or buttons are active at the same time.

Modifier names

The following modifiers can be used:

  • ctrl
  • alt
  • altGraph
  • shift
  • meta
  • win (the windows key)
  • double-click (The trigger matches a double-click. This can include "double-clicks" on keys, e.g., shift double-click A works as expected.)

Mouse buttons and scrolling

  • button1 (left mouse button)
  • button2 (middle mouse button)
  • button3 (right mouse button)
  • scroll (The trigger matches scroll events (both horizontal and vertical). Additional keys and modifiers may be present, e.g., shift A scroll matches when scrolling while pressing the shift and A keys. This modifier can only be used to trigger ScrollBehaviours.)

Key names

Key names are the usual alphanumeric and function keys:

  • A ... Z (Note that letter keys are always upper-case.)
  • 0 ... 9
  • F1 ... F24

Moreover the following special key names are supported (as in the AWTKeyStroke.getAWTKeyStroke(String) method):

  • ENTER
  • BACK_SPACE
  • TAB
  • CANCEL
  • CLEAR
  • COMPOSE
  • PAUSE
  • CAPS_LOCK
  • ESCAPE
  • SPACE
  • PAGE_UP
  • PAGE_DOWN
  • END
  • HOME
  • BEGIN
  • COMMA
  • PERIOD
  • SLASH
  • SEMICOLON
  • EQUALS
  • OPEN_BRACKET
  • BACK_SLASH
  • CLOSE_BRACKET

These are names for cursor keys:

  • LEFT
  • UP
  • RIGHT
  • DOWN

These are names for the numpad keys:

  • NUMPAD0 ... NUMPAD9
  • MULTIPLY
  • ADD
  • SEPARATOR
  • SUBTRACT
  • DECIMAL
  • DIVIDE
  • DELETE
  • NUM_LOCK
  • SCROLL_LOCK
Clone this wiki locally