Class: Navigator
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:41
Class responsible for determining where focus should move in response to keyboard navigation commands.
Extended by
Properties index
| Property | Description |
|---|---|
| rules | Map from classes to a corresponding ruleset to handle navigation from instances of that class. |
| navigationLoops | Whether or not navigation loops around when reaching the end. |
Methods index
| Method | Description |
|---|---|
| addNavigationPolicy | Adds a navigation ruleset to this Navigator. |
| getFirstChild | Returns the first child of the given object instance, if any. |
| getParent | Returns the parent of the given object instance, if any. |
| getNextSibling | Returns the next sibling of the given object instance, if any. |
| getPreviousSibling | Returns the previous sibling of the given object instance, if any. |
| getPreviousNode | Returns the previous node relative to the given node. |
| getOutNode | Returns the node to the left of the given node. |
| getNextNode | Returns next node relative to the given node. |
| getInNode | Returns the node to the right of the given node. |
| setNavigationLoops | Sets whether or not navigation should loop around when reaching the end of the workspace. |
| getNavigationLoops | Returns whether or not navigation loops around when reaching the end of the workspace. |
| getNavigableItems | Returns the navigable top-level items of a tree, in navigation order. |
| getFirstNode | Get the first navigable node on the workspace, or null if none exist. |
| getLastNode | Get the last navigable node on the workspace, or null if none exist. |
| transitionAllowed | Determines whether navigation is allowed between two nodes. |
| getTopLevelItems | Returns a list of all top-level focusable items on the given node's focusable tree. |
| isNavigable | Returns whether or not the given node is navigable. |
| getSourceBlockFromNode | Returns the block that the given node is a child of. |
Constructors
Constructor
new Navigator(): Navigator;
Returns
Navigator
Properties
rules
protected rules: RuleList<any>;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:46
Map from classes to a corresponding ruleset to handle navigation from instances of that class.
navigationLoops
protected navigationLoops: boolean = true;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:59
Whether or not navigation loops around when reaching the end.
Methods
addNavigationPolicy()
addNavigationPolicy(policy): void;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:67
Adds a navigation ruleset to this Navigator.
Parameters
| Parameter | Type | Description |
|---|---|---|
policy | INavigationPolicy<any> | A ruleset that determines where focus should move starting from an instance of its managed class. |
Returns
void
getFirstChild()
getFirstChild(current): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:91
Returns the first child of the given object instance, if any.
Parameters
| Parameter | Type | Description |
|---|---|---|
current | IFocusableNode | The object to retrieve the first child of. |
Returns
IFocusableNode | null
The first child node of the given object, if any.
getParent()
getParent(current): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:106
Returns the parent of the given object instance, if any.
Parameters
| Parameter | Type | Description |
|---|---|---|
current | IFocusableNode | The object to retrieve the parent of. |
Returns
IFocusableNode | null
The parent node of the given object, if any.
getNextSibling()
getNextSibling(current): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:119
Returns the next sibling of the given object instance, if any.
Parameters
| Parameter | Type | Description |
|---|---|---|
current | IFocusableNode | The object to retrieve the next sibling node of. |
Returns
IFocusableNode | null
The next sibling node of the given object, if any.
getPreviousSibling()
getPreviousSibling(current): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:134
Returns the previous sibling of the given object instance, if any.
Parameters
| Parameter | Type | Description |
|---|---|---|
current | IFocusableNode | The object to retrieve the previous sibling node of. |
Returns
IFocusableNode | null
The previous sibling node of the given object, if any.
getPreviousNode()
getPreviousNode(node?): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:151
Returns the previous node relative to the given node.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | IFocusableNode | null | The node to navigate relative to, defaults to the currently focused node. |
Returns
IFocusableNode | null
The previous node, generally on the "row" visually above the specified node, or null if there is none.
getOutNode()
getOutNode(node?): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:184
Returns the node to the left of the given node.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | IFocusableNode | null | The node to navigate relative to, defaults to the currently focused node. |
Returns
IFocusableNode | null
The node to the left of the given node, within the same visual "row" as the given node, or null if there is none.
getNextNode()
getNextNode(node?): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:196
Returns next node relative to the given node.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | IFocusableNode | null | The node to navigate relative to, defaults to the currently focused node. |
Returns
IFocusableNode | null
The next node, generally on the "row" visually below the specified node, or null if there is none.
getInNode()
getInNode(node?): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:216
Returns the node to the right of the given node.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | IFocusableNode | null | The node to navigate relative to, defaults to the currently focused node. |
Returns
IFocusableNode | null
The node to the right of the given node, within the same visual "row" as the given node, or null if there is none.
setNavigationLoops()
setNavigationLoops(loops): void;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:327
Sets whether or not navigation should loop around when reaching the end of the workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
loops | boolean | True if navigation should loop around, otherwise false. |
Returns
void
getNavigationLoops()
getNavigationLoops(): boolean;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:335
Returns whether or not navigation loops around when reaching the end of the workspace.
Returns
boolean
getNavigableItems()
getNavigableItems(root?): IFocusableNode[];
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:350
Returns the navigable top-level items of a tree, in navigation order.
For a workspace these are its stacks and comments; for a toolbox its categories; for a flyout its blocks, buttons and labels.
Parameters
| Parameter | Type | Description |
|---|---|---|
root | IFocusableNode | undefined | The root node of the tree to list, defaulting to the root of the currently focused tree. |
Returns
The navigable top-level items, or an empty list if there is no tree to list.
getFirstNode()
getFirstNode(): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:363
Get the first navigable node on the workspace, or null if none exist.
Returns
IFocusableNode | null
The first navigable node on the workspace, or null.
getLastNode()
getLastNode(): IFocusableNode | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:375
Get the last navigable node on the workspace, or null if none exist.
Returns
IFocusableNode | null
The last navigable node on the workspace, or null.
transitionAllowed()
protected transitionAllowed(
current,
candidate,
direction
): boolean;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:391
Determines whether navigation is allowed between two nodes.
Parameters
| Parameter | Type | Description |
|---|---|---|
current | IFocusableNode | The starting node for proposed navigation. |
candidate | IFocusableNode | The proposed destination node. |
direction | NavigationDirection | The direction in which the user is navigating. |
Returns
boolean
True if navigation should be allowed to proceed, or false to find a different candidate.
getTopLevelItems()
protected getTopLevelItems(current): IFocusableNode[];
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:493
Returns a list of all top-level focusable items on the given node's focusable tree.
Parameters
| Parameter | Type | Description |
|---|---|---|
current | IFocusableNode | The node whose root focusable tree to retrieve the top-level items of. |
Returns
A list of all top-level items on the given node's parent tree.
isNavigable()
protected isNavigable(node): boolean | undefined;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:504
Returns whether or not the given node is navigable.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | IFocusableNode | A focusable node to check the navigability of. |
Returns
boolean | undefined
True if the node is navigable, otherwise false.
getSourceBlockFromNode()
getSourceBlockFromNode(node): BlockSvg | null;
Defined in: packages/blockly/core/keyboard_nav/navigators/navigator.ts:513
Returns the block that the given node is a child of.
Parameters
| Parameter | Type |
|---|---|
node | IFocusableNode | null |
Returns
BlockSvg | null
The parent block of the node if any, otherwise null.