Module org.snapfx

Class DockShortcutController

java.lang.Object
org.snapfx.shortcuts.DockShortcutController

public final class DockShortcutController extends Object
Manages framework shortcut bindings and resolves matching shortcut actions for key events.

This controller is framework-internal implementation detail used by SnapFX to keep shortcut state and matching logic isolated from facade orchestration code.

  • Constructor Details

    • DockShortcutController

      public DockShortcutController()
      Creates a controller with the default shortcut mapping.
  • Method Details

    • resetToDefaults

      public void resetToDefaults()
      Restores the default framework shortcut mapping.
    • setShortcut

      public void setShortcut(DockShortcutAction action, javafx.scene.input.KeyCombination keyCombination)
      Assigns or removes a key binding for a built-in shortcut action.
      Parameters:
      action - shortcut action to configure
      keyCombination - key combination to assign, or null to remove the binding
    • clearShortcut

      public void clearShortcut(DockShortcutAction action)
      Removes the key binding for a shortcut action.
      Parameters:
      action - shortcut action to clear
    • getShortcut

      public javafx.scene.input.KeyCombination getShortcut(DockShortcutAction action)
      Returns the configured key binding for a shortcut action.
      Parameters:
      action - shortcut action to query
      Returns:
      configured key combination, or null
    • getShortcutsSnapshot

      public Map<DockShortcutAction,javafx.scene.input.KeyCombination> getShortcutsSnapshot()
      Returns an immutable snapshot of all current shortcut bindings.
      Returns:
      immutable snapshot of shortcut bindings
    • resolveShortcutAction

      public DockShortcutAction resolveShortcutAction(javafx.scene.input.KeyEvent event)
      Resolves the shortcut action that matches the given key event.
      Parameters:
      event - key event to evaluate
      Returns:
      matching shortcut action, or null when no mapping matches
    • bindFloatingShortcutScene

      public void bindFloatingShortcutScene(DockFloatingWindow floatingWindow, javafx.event.EventHandler<javafx.scene.input.KeyEvent> keyEventFilter)
      Binds the framework shortcut key filter to the current scene of a floating window.

      When the floating window scene changes, this method removes the filter from the previous scene and installs it on the new one.

      Parameters:
      floatingWindow - floating window whose scene should receive shortcut handling
      keyEventFilter - key filter used for framework shortcuts
    • unbindFloatingShortcutScene

      public void unbindFloatingShortcutScene(DockFloatingWindow floatingWindow, javafx.event.EventHandler<javafx.scene.input.KeyEvent> keyEventFilter)
      Removes the framework shortcut key filter binding for a floating window scene.
      Parameters:
      floatingWindow - floating window whose bound scene should be unbound
      keyEventFilter - key filter previously installed for framework shortcuts
    • resolveNodeFromEventTarget

      public javafx.scene.Node resolveNodeFromEventTarget(Object eventTarget)
      Resolves a node from an event target object.
      Parameters:
      eventTarget - event target object (Node, Scene, or other)
      Returns:
      resolved node, or null
    • resolveFocusedNode

      public javafx.scene.Node resolveFocusedNode(Object eventTarget, javafx.scene.Scene fallbackScene)
      Resolves the focused node associated with an event target.
      Parameters:
      eventTarget - event target object (Node, Scene, or other)
      fallbackScene - fallback scene used when target does not provide a focus owner
      Returns:
      focused node, or null
    • resolveSceneFromEventTarget

      public javafx.scene.Scene resolveSceneFromEventTarget(Object eventTarget)
      Resolves a scene from an event target object.
      Parameters:
      eventTarget - event target object (Scene, Node, or other)
      Returns:
      resolved scene, or null
    • resolveSceneFromNode

      public javafx.scene.Scene resolveSceneFromNode(javafx.scene.Node node)
      Resolves a scene from a node.
      Parameters:
      node - source node
      Returns:
      node scene, or null
    • resolveActiveTabPane

      public javafx.scene.control.TabPane resolveActiveTabPane(Object eventTarget, javafx.scene.Scene fallbackScene, javafx.scene.Node fallbackRoot)
      Resolves the currently active tab pane from event/focus context and an optional root fallback.
      Parameters:
      eventTarget - event target object (Node, Scene, or other)
      fallbackScene - fallback scene used for focus lookup
      fallbackRoot - fallback root node searched when no target/focus tab pane is found
      Returns:
      resolved tab pane, or null
    • findTabPaneInHierarchy

      public javafx.scene.control.TabPane findTabPaneInHierarchy(javafx.scene.Node node)
      Finds the nearest TabPane while traversing parent hierarchy upward.
      Parameters:
      node - start node
      Returns:
      nearest ancestor tab pane, or null
    • findFirstTabPane

      public javafx.scene.control.TabPane findFirstTabPane(javafx.scene.Node root)
      Finds the first TabPane in a depth-first traversal of a node subtree.
      Parameters:
      root - traversal root node
      Returns:
      first tab pane found, or null
    • selectTabRelative

      public boolean selectTabRelative(int direction, Object eventTarget, javafx.scene.Scene fallbackScene, javafx.scene.Node fallbackRoot)
      Selects the next/previous tab relative to the currently selected tab in the active tab pane.
      Parameters:
      direction - selection direction (+1 for next, -1 for previous)
      eventTarget - event target object (Node, Scene, or other)
      fallbackScene - fallback scene used for focus lookup
      fallbackRoot - fallback root node searched when no target/focus tab pane is found
      Returns:
      true when a tab selection changed; otherwise false
    • resolveActiveDockNode

      public DockNode resolveActiveDockNode(Object eventTarget, javafx.scene.Scene fallbackScene, DockElement fallbackRoot)
      Resolves the active DockNode for shortcut actions from event/focus context with root fallback.
      Parameters:
      eventTarget - event target object (Node, Scene, or other)
      fallbackScene - fallback scene used for focus lookup
      fallbackRoot - fallback dock root used when event/focus lookup yields no node
      Returns:
      resolved active dock node, or null