Blockly. BasicCursor
Constructor
BasicCursor
new BasicCursor()
Class for a basic cursor. This will allow the user to get to all nodes in the AST by hitting next or previous.
- Extends
- Blockly.Cursor
Property
colour
unknown
The colour of the marker.
- Inherited from
- Blockly.Marker#colour
Methods
dispose
dispose()
Dispose of this marker.
- Inherited from
- Blockly.Marker#dispose
draw
draw()
Redraw the current marker.
- Inherited from
- Blockly.Marker#draw
getCurNode
getCurNode() returns Blockly.ASTNode
Gets the current location of the marker.
- Inherited from
- Blockly.Marker#getCurNode
- Returns
-
The current field, connection, or block the marker is on.
getDrawer
getDrawer() returns Blockly.blockRendering.MarkerSvg
Get the current drawer for the marker.
- Inherited from
- Blockly.Marker#getDrawer
- Returns
-
The object in charge of drawing the marker.
getNextNode_
getNextNode_(node, isValid) returns Blockly.ASTNode
Uses pre order traversal to navigate the Blockly AST. This will allow a user to easily navigate the entire Blockly AST without having to go in and out levels on the tree.
Parameter |
|
---|---|
node |
The current position in the AST. |
isValid |
function(Blockly.ASTNode) A function true/false depending on whether the given node should be traversed. Value must not be null. |
- Returns
-
Blockly.ASTNode
The next node in the traversal.
getPreviousNode_
getPreviousNode_(node, isValid) returns Blockly.ASTNode
Reverses the pre order traversal in order to find the previous node. This will allow a user to easily navigate the entire Blockly AST without having to go in and out levels on the tree.
Parameter |
|
---|---|
node |
The current position in the AST. |
isValid |
function(Blockly.ASTNode) A function true/false depending on whether the given node should be traversed. Value must not be null. |
- Returns
-
Blockly.ASTNode
The previous node in the traversal or null if no previous node exists.
hide
hide()
Hide the marker SVG.
- Inherited from
- Blockly.Marker#hide
in
in() returns Blockly.ASTNode
For a basic cursor we only have the ability to go next and previous, so in will also allow the user to get to the next node in the pre order traversal.
- Inherited from
- Blockly.BasicCursor#in
- Returns
-
The next node, or null if the current node is not set or there is no next value.
next
next() returns Blockly.ASTNode
Find the next node in the pre order traversal.
- Inherited from
- Blockly.BasicCursor#next
- Returns
-
The next node, or null if the current node is not set or there is no next value.
onBlocklyAction
onBlocklyAction(action) returns boolean
Handles the given action. This is only triggered when keyboard navigation is enabled.
Parameter |
|
---|---|
action |
The action to be handled. Value must not be null. |
- Inherited from
- Blockly.Cursor#onBlocklyAction
- Implements
- Blockly.IBlocklyActionable#onBlocklyAction
- Returns
-
True if the action has been handled, false otherwise.
out
out() returns Blockly.ASTNode
For a basic cursor we only have the ability to go next and previous, so out will allow the user to get to the previous node in the pre order traversal.
- Inherited from
- Blockly.BasicCursor#out
- Returns
-
The previous node, or null if the current node is not set or there is no previous value.
prev
prev() returns Blockly.ASTNode
Find the previous node in the pre order traversal.
- Inherited from
- Blockly.BasicCursor#prev
- Returns
-
The previous node, or null if the current node is not set or there is no previous value.
setCurNode
setCurNode(newNode)
Set the location of the marker and call the update method. Setting isStack to true will only work if the newLocation is the top most output or previous connection on a stack.
Parameter |
|
---|---|
newNode |
The new location of the marker. |
- Inherited from
- Blockly.Marker#setCurNode
setDrawer
setDrawer(drawer)
Sets the object in charge of drawing the marker.
Parameter |
|
---|---|
drawer |
The object in charge of drawing the marker. |
- Inherited from
- Blockly.Marker#setDrawer
validNode_
validNode_(node) returns boolean
Decides what nodes to traverse and which ones to skip. Currently, it skips output, stack and workspace nodes.
Parameter |
|
---|---|
node |
The AST node to check whether it is valid. |
- Returns
-
boolean
True if the node should be visited, false otherwise.