Class TLspKeyActionController

All Implemented Interfaces:
ILcdAWTEventListener, ILspController

public class TLspKeyActionController extends ALspActionController

A chainable controller that performs certain actions based on keyboard interaction.

To use this controller in a TLspFXView, use the JavaFX-based constructor.

Note: Only the first pressed event will trigger an action. All other pressed events will have no effect until a released event is received.

Since:
2012.0
  • Constructor Details

    • TLspKeyActionController

      public TLspKeyActionController(ILcdAction aAction, int aKeyCode)
      Constructor for a TLspKeyActionController that will execute the passed action when a key identified by the passed key code is pressed. No action will be executed when the key is released. The default modifiers are used, none.

      The "virtual key" constants defined in KeyEvent (KeyEvent.VK_*)can be used to specify the key code.

      Parameters:
      aAction - an action that will be called when the key corresponding to aKeyCode is released.
      aKeyCode - the key code identifying the key this controller will interact with.
    • TLspKeyActionController

      public TLspKeyActionController(ILcdAction aAction, int aKeyCode, int aModifiers)
      Constructor for a TLspKeyActionController that will execute the passed action when a key identified by the passed key code is pressed in combination with the specified modifiers. No action will be executed when the key is released.

      The "virtual key" constants defined in KeyEvent (KeyEvent.VK_*)can be used to specify the key code.

      The modifiers can consist of any combination of:

      • java.awt.event.InputEvent.SHIFT_DOWN_MASK
      • java.awt.event.InputEvent.CTRL_DOWN_MASK
      • java.awt.event.InputEvent.META_DOWN_MASK
      • java.awt.event.InputEvent.ALT_DOWN_MASK
      • java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK
      Pass 0 to indicate no modifiers.
      Parameters:
      aAction - an action that will be called when the key corresponding to aKeyCode is released.
      aKeyCode - the key code identifying the key this controller will interact with.
      aModifiers - the modifiers that have to be present for the action to be triggered.
    • TLspKeyActionController

      public TLspKeyActionController(ILcdAction aPressedAction, ILcdAction aReleasedAction, int aKeyCode)
      Constructor for a TLspKeyActionController. The pressed action will be executed when the specified key is pressed, the release action when the specified key is released. A typical use case is starting and stopping an animation. The default modifiers are used, none.

      The "virtual key" constants defined in KeyEvent (KeyEvent.VK_*)can be used to specify the key code.

      Parameters:
      aPressedAction - an action that will be called when the key corresponding to aKeyCode is pressed.
      aReleasedAction - an action that will be called when the key corresponding to aKeyCode is released.
      aKeyCode - the key code identifying the key this controller will interact with.
    • TLspKeyActionController

      public TLspKeyActionController(ILcdAction aPressedAction, ILcdAction aReleasedAction, KeyCodeCombination aKeyCodeCombination)
      JavaFX-based constructor for a TLspKeyActionController. The pressed action will be executed when the specified key is pressed in combination with the specified modifiers, the release action when the specified key is released in combination with the specified modifiers. A typical use case is starting and stopping an animation.
      Parameters:
      aPressedAction - an action that will be called when the key corresponding to aKeyCodeCombination is pressed.
      aReleasedAction - an action that will be called when the key corresponding to aKeyCodeCombination is released.
      aKeyCodeCombination - the key code and modifier combination that will trigger this controller's actions
      Since:
      2020.0
  • Method Details

    • startInteractionImpl

      protected void startInteractionImpl(ILspView aView)
      Description copied from class: ALspController
      The specific implementation of startInteraction for this controller.
      Overrides:
      startInteractionImpl in class ALspController
      Parameters:
      aView - the view to start interaction with.
    • terminateInteractionImpl

      protected void terminateInteractionImpl(ILspView aView)
      Description copied from class: ALspController
      The specific implementation of terminateInteraction for this controller.
      Overrides:
      terminateInteractionImpl in class ALspController
      Parameters:
      aView - the view to terminate interaction with.
    • handleAWTEventImpl

      public AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
      Description copied from class: ALspController
      Called by handleAWTEvent. Returns null when the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen with TLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.
      Specified by:
      handleAWTEventImpl in class ALspController
      Parameters:
      aAWTEvent - the event to be handled.
      Returns:
      null when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
    • handleFXEventImpl

      public Event handleFXEventImpl(Event aEvent)
      Description copied from class: ALspController
      Called by handleFXEvent. Returns null when the controller consumed the event. When the controller did not use the given event, it is returned unaltered.
      Overrides:
      handleFXEventImpl in class ALspController
      Parameters:
      aEvent - the event to be handled.
      Returns:
      null when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.