FocusNodeCommand
A group of commands for managing focus of UI elements. All commands extend from the base class GenericFocusNodeCommand, which in turn extends RemoteCommand.
Supported Actions
| Action | Class | Description |
|---|---|---|
requestFocus | FocusNodeRequestFocusCommand | Request focus for an element |
unfocus | FocusNodeUnfocusCommand | Remove focus from an element |
nextFocus | FocusNodeNextFocusCommand | Move focus to the next element |
previousFocus | FocusNodePreviousFocusCommand | Move focus to the previous element |
focusInDirection | FocusNodeFocusInDirectionCommand | Move focus in a specified direction |
JSON Examples
Request Focus
{
"type": "command",
"controllerId": "text_field_id",
"commandData": {
"type": "focusNode",
"action": "requestFocus"
}
}
Request Focus for Specific Node
{
"type": "command",
"controllerId": "focus_scope_id",
"commandData": {
"type": "focusNode",
"action": "requestFocus",
"nodeId": "specific_node_id"
}
}
Unfocus
{
"type": "command",
"controllerId": "text_field_id",
"commandData": {
"type": "focusNode",
"action": "unfocus",
"disposition": "scope"
}
}
Available disposition values:
scope- unfocus within the current scopepreviouslyFocusedChild- return focus to the previously focused child
Move to Next Focusable Element
{
"type": "command",
"controllerId": "focus_scope_id",
"commandData": {
"type": "focusNode",
"action": "nextFocus"
}
}
Move to Previous Focusable Element
{
"type": "command",
"controllerId": "focus_scope_id",
"commandData": {
"type": "focusNode",
"action": "previousFocus"
}
}
Move Focus in Direction
{
"type": "command",
"controllerId": "focus_scope_id",
"commandData": {
"type": "focusNode",
"action": "focusInDirection",
"direction": "down"
}
}
Available directions (TraversalDirection):
up- upwarddown- downwardleft- to the leftright- to the right
Command Classes
FocusNodeRequestFocusCommand
final class FocusNodeRequestFocusCommand extends GenericFocusNodeCommand {
final String? nodeId;
const FocusNodeRequestFocusCommand({
required super.controllerId,
this.nodeId,
...
});
}
FocusNodeUnfocusCommand
final class FocusNodeUnfocusCommand extends GenericFocusNodeCommand {
final UnfocusDisposition disposition;
const FocusNodeUnfocusCommand({
required super.controllerId,
required this.disposition,
...
});
}
FocusNodeNextFocusCommand
final class FocusNodeNextFocusCommand extends GenericFocusNodeCommand {
const FocusNodeNextFocusCommand({
required super.controllerId,
...
});
}
FocusNodePreviousFocusCommand
final class FocusNodePreviousFocusCommand extends GenericFocusNodeCommand {
const FocusNodePreviousFocusCommand({
required super.controllerId,
...
});
}
FocusNodeFocusInDirectionCommand
final class FocusNodeFocusInDirectionCommand extends GenericFocusNodeCommand {
final TraversalDirection direction;
const FocusNodeFocusInDirectionCommand({
required super.controllerId,
required this.direction,
...
});
}
Related Types
- RemoteCommand - base command class