Class KeyboardFocusStack
java.lang.Object
eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardFocusStack
Manages a stack-based keyboard focus system for interactive 3D components.
The focus stack determines which KeyboardInputHandler currently receives
keyboard events. When a component gains focus (e.g., by being clicked), it is pushed
onto the stack and the previous focus owner is notified. When the component releases
focus (e.g., pressing ESC), the previous handler is restored.
The default handler at the bottom of the stack is a
WorldNavigationUserInputTracker, which handles WASD/arrow-key camera movement
when no other component has focus.
Focus flow example:
// Initial state: WorldNavigationUserInputTracker has focus (camera movement)
// User clicks on a text editor:
focusStack.pushFocusOwner(textEditor);
// Now textEditor receives keyboard events
// User presses ESC:
focusStack.popFocusOwner();
// Camera movement is restored
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKeyboardFocusStack(ViewPanel viewPanel) Creates a new focus stack for the given view panel, withWorldNavigationUserInputTrackeras the default focus owner. -
Method Summary
Modifier and TypeMethodDescriptionReturns the handler that currently has keyboard focus.voidRemoves the current focus owner from the stack and restores focus to the previous handler.booleanpushFocusOwner(KeyboardInputHandler newInputHandler) Pushes a new handler onto the focus stack, making it the current focus owner.
-
Constructor Details
-
KeyboardFocusStack
Creates a new focus stack for the given view panel, withWorldNavigationUserInputTrackeras the default focus owner.- Parameters:
viewPanel- the view panel this focus stack belongs to
-
-
Method Details
-
getCurrentFocusOwner
Returns the handler that currently has keyboard focus.- Returns:
- the current focus owner
-
popFocusOwner
public void popFocusOwner()Removes the current focus owner from the stack and restores focus to the previous handler. If the stack is empty, no action is taken. -
pushFocusOwner
Pushes a new handler onto the focus stack, making it the current focus owner. The previous focus owner is notified viaKeyboardInputHandler.focusLost(eu.svjatoslav.sixth.e3d.gui.ViewPanel)and preserved on the stack for later restoration.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
-