FocusManager class abstract
Manages focus state and hierarchy for a set of FocusNodes.
Constructors
Properties
- changed ← FocusCallback?
-
Set a callback to be invoked when focus changes.
Pass null to remove the callback.
no getter
- hashCode → int
-
The hash code for this object.
no setterinherited
- nativePointerAddress → int?
-
Get the native pointer address for this focus manager.
Used internally for sharing focus managers across FFI boundaries.
Returns null on platforms that don't support this (e.g., web).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollIntoView ← ScrollIntoViewCallback?
-
Set a callback to be invoked when focus changes to an element in a
Dart-mounted artboard (root artboard with no native host).
This allows Dart to handle scrolling the focused element into view.
Pass null to remove the callback.
no getter
Methods
-
addChild(
FocusNode? parent, FocusNode child) → void -
Add a child node to the hierarchy.
If
parentis null, the child is added as a root node. -
clearFocus(
) → void - Clear the current focus.
-
descendFocusToLeafAllRoots(
) → void - Re-applies the focus-rests-on-a-leaf rule to the current target: a target whose hidden child became visible has silently turned into a scope, and focus belongs on the child instead.
-
detachChild(
FocusNode child) → void - Detach a child node from the hierarchy WITHOUT clearing focus. Use this when reordering an existing node (e.g. rebuilding the focus hierarchy) so the primary focus and its blur/focus callbacks are preserved. For genuine removal use removeChild instead.
-
dispose(
) → void - Dispose of this focus manager and release native resources.
-
dropFocusIfFocusTargetHidden(
) → void - Clear focus if the current target is hidden.
-
finishAllPendingFocusRequests(
) → void - Finishes the frame: applies what it can and discards the rest, so a request for a target that never becomes focusable can't linger and steal focus in a later frame.
-
focusDown(
) → bool - Move focus to the nearest focusable node below. Returns true if focus was moved.
-
focusLeft(
) → bool - Move focus to the nearest focusable node to the left. Returns true if focus was moved.
-
focusNext(
) → bool - Move focus to the next focusable node. Returns true if focus was moved.
-
focusPrevious(
) → bool - Move focus to the previous focusable node. Returns true if focus was moved.
-
focusRight(
) → bool - Move focus to the nearest focusable node to the right. Returns true if focus was moved.
-
focusUp(
) → bool - Move focus to the nearest focusable node above. Returns true if focus was moved.
-
hasFocus(
FocusNode node) → bool - Check if the given node or any of its descendants has focus.
-
hasPrimaryFocus(
FocusNode node) → bool - Check if the given node is the primary focus.
-
isFocusInArtboard(
int artboardPtr) → bool -
Check if the primary focus is inside the given artboard (or a nested
artboard within it). Returns true if the focused element's artboard is
the given artboard or a descendant of it.
artboardPtrshould be a native artboard pointer address. -
keyInput(
int key, int modifiers, bool isPressed, bool isRepeat) → bool - Route key input to the focused node. Returns true if the input was handled.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
primaryFocusAcceptsText(
) → bool - Whether the focused element (or an ancestor it bubbles to) is a text input, i.e. something that consumes typed text. False when nothing is focused.
-
primaryFocusArtboardPtr(
) → int? - Get the root native artboard pointer address that contains the primary focus. This walks up the nested artboard chain to find the topmost artboard. Returns null if there is no focus or the focusable has no artboard.
-
primaryFocusBounds(
) → ({double maxX, double maxY, double minX, double minY})? - Get the world bounds of the primary focus node. Returns null if there is no focus or the focused node has no bounds. Bounds are in root artboard space.
-
primaryFocusImmediateArtboardPtr(
) → int? - Get the immediate native artboard pointer address that contains the primary focus. Unlike primaryFocusArtboardPtr, this does NOT walk up the nested artboard chain - it returns the direct parent artboard. This can be compared against MountedArtboard native pointer addresses to find which NestedArtboard hosts the focused element.
-
processAllPendingFocusRequests(
) → void - Applies focus changes queued by focus actions, keeping any that can't take yet for a later call.
-
removeChild(
FocusNode child) → void - Remove a child node from the hierarchy. The child knows its own parent, so no parent parameter is needed.
-
requestClearFocus(
) → void - Queue-and-retry counterpart of clearFocus. See requestFocus.
-
requestFocus(
FocusNode node) → void - Queue-and-retry counterpart of setFocus, for a focus action.
-
requestTraversal(
int traversalKind) → void -
Queue-and-retry counterpart of the directional focus moves. See
requestFocus.
traversalKindis 0=next, 1=previous, 2=up, 3=down, 4=left, 5=right. -
selectedText(
) → String - The selected text of the focused element (e.g. a focused text input's current selection). Empty when nothing with a text selection is focused. Lets hosts implement clipboard copy/cut, which the runtime can't do itself (no system clipboard access).
-
setFocus(
FocusNode node) → void - Set focus to the given node.
-
textInput(
String text) → bool - Route text input to the focused node. Returns true if the input was handled.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
make(
) → FocusManager - Create a new FocusManager.