Class KeyboardFocusStack
java.lang.Object
eu.svjatoslav.aukio.e3d.gui.humaninput.KeyboardFocusStack
Manages keyboard focus for interactive 3D components.
Exactly one KeyboardInputHandler has keyboard focus at a time.
When a component gains focus (e.g., by being clicked), the previous focus
owner is notified and forgotten. When the component releases focus (ESC or
middle mouse button), focus falls back to the default handler — never to a
previously focused component (there is no focus stack).
The default handler is a WorldNavigationUserInputTracker, which
handles WASD/arrow-key camera movement while no component has focus.
Focus flow example:
// Initial state: WorldNavigationUserInputTracker has focus (camera movement)
// User clicks on a text editor:
focus.pushFocusOwner(textEditor);
// Now textEditor receives keyboard events
// User presses ESC or middle-clicks the editor:
focus.popFocusOwner();
// Camera movement is active again
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKeyboardFocusStack(ViewPanel viewPanel) Creates a new focus manager for the given view panel, withWorldNavigationUserInputTrackeras the default focus owner. -
Method Summary
Modifier and TypeMethodDescriptionReturns the handler that currently has keyboard focus.voidReleases focus from the current focus owner; focus falls back to the default camera navigation handler.booleanpushFocusOwner(KeyboardInputHandler newInputHandler) Gives keyboard focus to the given handler.
-
Constructor Details
-
KeyboardFocusStack
Creates a new focus manager for the given view panel, withWorldNavigationUserInputTrackeras the default focus owner.- Parameters:
viewPanel- the view panel this focus manager belongs to
-
-
Method Details
-
getCurrentFocusOwner
Returns the handler that currently has keyboard focus. When no component is focused, this is the default camera navigation handler.- Returns:
- the current focus owner
-
popFocusOwner
public void popFocusOwner()Releases focus from the current focus owner; focus falls back to the default camera navigation handler. No previously focused component is restored — focus is single-level, not a stack. -
pushFocusOwner
Gives keyboard focus to the given handler. The previous focus owner is notified viaKeyboardInputHandler.focusLost(ViewPanel)and forgotten.If the given handler is already the current focus owner, this method does nothing and returns
false.- Parameters:
newInputHandler- the handler to receive keyboard focus- Returns:
trueif the view needs to be repainted as a result
-