Package docking

Class KeyBindingOverrideKeyEventDispatcher

java.lang.Object
docking.KeyBindingOverrideKeyEventDispatcher
All Implemented Interfaces:
KeyEventDispatcher

public class KeyBindingOverrideKeyEventDispatcher extends Object implements KeyEventDispatcher
Allows Ghidra to give preference to its key event processing over the default Java key event processing. See dispatchKeyEvent(KeyEvent) for a more detailed explanation of how Ghidra processes key events.

install() must be called in order to install this Singleton into Java's key event processing system.

Keybindings are processed here to manage how DockingActions will get executed. The basic action processing flow is:

  1. System actions (e.g., F1 for help)
  2. Java text components
  3. Java widget key listeners
  4. Java action map bindings
  5. ComponentBasedDockingActions
  6. ComponentProvider local actions
  7. Tool global actions
When a key event is processed, if that event has a binding at one of these levels, then that binding will be processed, either by our framework or the default Java processing framework. Our framework allows for multiple actions to share a key bindings. When that happens, the MultipleKeyAction class is responsible for determining the correct priority for the action to be processed. If there is more than one action that maps to a binding, then the user will be shown a dialog to choose which action to execute.
  • Constructor Details

    • KeyBindingOverrideKeyEventDispatcher

      public KeyBindingOverrideKeyEventDispatcher()
  • Method Details

    • dispatchKeyEvent

      public boolean dispatchKeyEvent(KeyEvent event)
      Overridden to change the Java's key event processing to insert Ghidra's top level tool key bindings into the event processing. Java's normal key event processing is:
      1. KeyListeners on the focused Component
      2. InputMap and ActionMap actions for the Component
      3. InputMap and ActionMap actions for the Component's parent, and so on up the Swing hierarchy
      Ghidra has altered this flow to be:
      1. Reserved keybinding actions
      2. KeyListeners on the focused Component
      3. InputMap and ActionMap actions for the Component
      4. Ghidra tool-level actions
      5. InputMap and ActionMap actions for the Component's parent, and so on up the Swing hierarchy
      This updated key event processing allows individual components to handle key events first, but then allows global Ghidra key bindings to be processed, allowing normal Java processing after Ghidra has had its chance to process the event.

      There are some exceptions to this processing chain:

      1. We don't do any processing when the focused component is an instance of JTextComponent.
      2. We don't do any processing if the active window is an instance of DockingDialog.
      Specified by:
      dispatchKeyEvent in interface KeyEventDispatcher
      See Also: