Skip to main content

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

PropertyDescription
rulesMap from classes to a corresponding ruleset to handle navigation from instances of that class.
navigationLoopsWhether or not navigation loops around when reaching the end.

Methods index

MethodDescription
addNavigationPolicyAdds a navigation ruleset to this Navigator.
getFirstChildReturns the first child of the given object instance, if any.
getParentReturns the parent of the given object instance, if any.
getNextSiblingReturns the next sibling of the given object instance, if any.
getPreviousSiblingReturns the previous sibling of the given object instance, if any.
getPreviousNodeReturns the previous node relative to the given node.
getOutNodeReturns the node to the left of the given node.
getNextNodeReturns next node relative to the given node.
getInNodeReturns the node to the right of the given node.
setNavigationLoopsSets whether or not navigation should loop around when reaching the end of the workspace.
getNavigationLoopsReturns whether or not navigation loops around when reaching the end of the workspace.
getNavigableItemsReturns the navigable top-level items of a tree, in navigation order.
getFirstNodeGet the first navigable node on the workspace, or null if none exist.
getLastNodeGet the last navigable node on the workspace, or null if none exist.
transitionAllowedDetermines whether navigation is allowed between two nodes.
getTopLevelItemsReturns a list of all top-level focusable items on the given node's focusable tree.
isNavigableReturns whether or not the given node is navigable.
getSourceBlockFromNodeReturns 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.


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

ParameterTypeDescription
policyINavigationPolicy<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

ParameterTypeDescription
currentIFocusableNodeThe 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

ParameterTypeDescription
currentIFocusableNodeThe 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

ParameterTypeDescription
currentIFocusableNodeThe 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

ParameterTypeDescription
currentIFocusableNodeThe 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

ParameterTypeDescription
nodeIFocusableNode | nullThe 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

ParameterTypeDescription
nodeIFocusableNode | nullThe 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

ParameterTypeDescription
nodeIFocusableNode | nullThe 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

ParameterTypeDescription
nodeIFocusableNode | nullThe 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

ParameterTypeDescription
loopsbooleanTrue 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

ParameterTypeDescription
rootIFocusableNode | undefinedThe root node of the tree to list, defaulting to the root of the currently focused tree.

Returns

IFocusableNode[]

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

ParameterTypeDescription
currentIFocusableNodeThe starting node for proposed navigation.
candidateIFocusableNodeThe proposed destination node.
directionNavigationDirectionThe 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

ParameterTypeDescription
currentIFocusableNodeThe node whose root focusable tree to retrieve the top-level items of.

Returns

IFocusableNode[]

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

ParameterTypeDescription
nodeIFocusableNodeA 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

ParameterType
nodeIFocusableNode | null

Returns

BlockSvg | null

The parent block of the node if any, otherwise null.