Blockly. BlockSvg
Constructor
BlockSvg
new BlockSvg(workspace, prototypeName, opt_id)
Class for a block's SVG representation. Not normally called directly, workspace.newBlock() is preferred.
Parameter |
|
---|---|
workspace |
The block's workspace. Value must not be null. |
prototypeName |
string Name of the language object containing type-specific functions for this block. Value may be null. |
opt_id |
Optional string Optional ID. Use this ID if provided, otherwise create a new ID. |
- Extends
- Blockly.Block
- Implements
- Blockly.IASTNodeLocationSvg
- Blockly.IBoundedElement
- Blockly.ICopyable
Properties
COLLAPSED_WARNING_ID
string
ID to give the "collapsed warnings" warning. Allows us to remove the "collapsed warnings" warning without removing any warnings that belong to the block.
INLINE
Constant for identifying rows that are to be rendered inline. Don't collide with Blockly.INPUT_VALUE and friends.
childBlocks_
unknown
- Inherited from
- Blockly.Block#childBlocks_
collapsed_
unknown
- Inherited from
- Blockly.Block#collapsed_
colour_
unknown
Colour of the block in '#RRGGBB' format.
- Inherited from
- Blockly.Block#colour_
comment
Block's comment icon (if any).
- Deprecated
- August 2019. Use getCommentIcon instead.
commentModel
unknown
A model of the comment attached to this block.
- Inherited from
- Blockly.Block#commentModel
compose
nullable function(non-null Blockly.BlockSvg)
An optional method called when a mutator dialog saves its content.
This function is called to modify the original block according to new
settings. This method must also be coupled with defining a decompose
method for the default mutation dialog button and UI to appear.
contextMenu
unknown
- Inherited from
- Blockly.Block#contextMenu
customContextMenu
nullable function(non-null Array of non-null Object)
An optional method for defining custom block context menu items.
data
unknown
Optional text data that round-trips between blocks and XML. Has no effect. May be used by 3rd parties for meta information.
- Inherited from
- Blockly.Block#data
decompose
nullable function(Blockly.WorkspaceSvg) returns non-null Blockly.BlockSvg
An optional method called when a mutator dialog is first opened.
This function must create and initialize a top-level block for the mutator
dialog, and return it. This function should also populate this top-level
block with any sub-blocks which are appropriate. This method must also be
coupled with defining a compose
method for the default mutation dialog
button and UI to appear.
disposed
unknown
Has this block been disposed of?
- Inherited from
- Blockly.Block#disposed
domToMutation
unknown
An optional deserialization method for defining how to deserialize the
mutation state. This must be coupled with defining mutationToDom
.
- Inherited from
- Blockly.Block#domToMutation
getDeveloperVariables
unknown
An optional property for declaring developer variables. Return a list of variable names for use by generators. Developer variables are never shown to the user, but are declared as global variables in the generated code.
- Inherited from
- Blockly.Block#getDeveloperVariables
hat
unknown
Name of the type of hat.
- Inherited from
- Blockly.Block#hat
height
Height of this block, not including any statement blocks above or below. Height is in workspace units.
id
unknown
- Inherited from
- Blockly.Block#id
- Implements
- Blockly.ICopyable#id
init
unknown
An optional method called during initialization.
- Inherited from
- Blockly.Block#init
inputList
unknown
- Inherited from
- Blockly.Block#inputList
inputsInline
unknown
- Inherited from
- Blockly.Block#inputsInline
inputsInlineDefault
unknown
- Inherited from
- Blockly.Block#inputsInlineDefault
isInFlyout
unknown
- Inherited from
- Blockly.Block#isInFlyout
isInMutator
unknown
- Inherited from
- Blockly.Block#isInMutator
isInsertionMarker_
unknown
True if this block is an insertion marker.
- Inherited from
- Blockly.Block#isInsertionMarker_
mutationToDom
unknown
An optional serialization method for defining how to serialize the
mutation state. This must be coupled with defining domToMutation
.
- Inherited from
- Blockly.Block#mutationToDom
mutator
Block's mutator icon (if any).
nextConnection
onchange
unknown
An optional callback method to use whenever the block's parent workspace changes. This is usually only called from the constructor, the block type initializer function, or an extension initializer function.
- Inherited from
- Blockly.Block#onchange
outputConnection
outputShape_
unknown
- Inherited from
- Blockly.Block#outputShape_
parentBlock_
unknown
- Inherited from
- Blockly.Block#parentBlock_
pathObject
Blockly.blockRendering.IPathObject
The renderer's path object.
previousConnection
rendered
boolean
renderingDebugger
nullable Blockly.blockRendering.Debug
An property used internally to reference the block's rendering debugger.
RTL
unknown
- Inherited from
- Blockly.Block#RTL
statementInputCount
unknown
A count of statement inputs on the block.
- Inherited from
- Blockly.Block#statementInputCount
style
non-null Blockly.Theme.BlockStyle
A block style object.
styleName_
unknown
Name of the block style.
- Inherited from
- Blockly.Block#styleName_
suppressPrefixSuffix
unknown
An optional property for suppressing adding STATEMENT_PREFIX and STATEMENT_SUFFIX to generated code.
- Inherited from
- Blockly.Block#suppressPrefixSuffix
svgGroup_
non-null Element
svgGroup_
non-null Element
tooltip
unknown
- Inherited from
- Blockly.Block#tooltip
type
unknown
- Inherited from
- Blockly.Block#type
warning
Block's warning icon (if any).
width
Width of this block, including any connected value blocks. Width is in workspace units.
workspace
non-null Blockly.WorkspaceSvg
workspace
non-null Blockly.WorkspaceSvg
workspace
non-null Blockly.WorkspaceSvg
Methods
addSelect
addSelect()
Select this block. Highlight it visually.
allInputsFilled
allInputsFilled(opt_shadowBlocksAreFilled) returns boolean
Recursively checks whether all statement and value inputs are filled with blocks. Also checks all following statement blocks in this stack.
Parameter |
|
---|---|
opt_shadowBlocksAreFilled |
Optional An optional argument controlling whether shadow blocks are counted as filled. Defaults to true. |
- Inherited from
- Blockly.Block#allInputsFilled
- Returns
-
True if all inputs are filled, false otherwise.
appendDummyInput
appendDummyInput(opt_name) returns Blockly.Input
Shortcut for appending a dummy input row.
Parameter |
|
---|---|
opt_name |
Optional Language-neutral identifier which may used to find this input again. Should be unique to this block. |
- Inherited from
- Blockly.Block#appendDummyInput
- Returns
-
The input object created.
appendStatementInput
appendStatementInput(name) returns Blockly.Input
Shortcut for appending a statement input row.
Parameter |
|
---|---|
name |
Language-neutral identifier which may used to find this input again. Should be unique to this block. |
- Inherited from
- Blockly.Block#appendStatementInput
- Returns
-
The input object created.
appendValueInput
appendValueInput(name) returns Blockly.Input
Shortcut for appending a value input row.
Parameter |
|
---|---|
name |
Language-neutral identifier which may used to find this input again. Should be unique to this block. |
- Inherited from
- Blockly.Block#appendValueInput
- Returns
-
The input object created.
applyColour
applyColour()
Change the colour of a block.
bringToFront
bringToFront()
Move this block to the front of the visible workspace.
bumpNeighbours
bumpNeighbours()
Bump unconnected blocks out of alignment. Two blocks which aren't actually connected should not coincidentally line up on screen.
dispose
dispose(healStack, animate)
Dispose of this block.
Parameter |
|
---|---|
healStack |
Optional boolean If true, then try to heal any gap by connecting the next statement with the previous statement. Otherwise, dispose of all children of this block. |
animate |
Optional boolean If true, show a disposal animation and sound. |
fadeForReplacement
fadeForReplacement(add)
Visual effect to show that if the dragging block is dropped, this block will be replaced. If a shadow block, it will disappear. Otherwise it will bump.
Parameter |
|
---|---|
add |
boolean True if highlighting should be added. |
generateContextMenu
generateContextMenu() returns Array of non-null Object
Generate the context menu for this block.
- Returns
-
Array of non-null Object
Context menu options
getBoundingRectangle
getBoundingRectangle() returns Blockly.utils.Rect
Returns the coordinates of a bounding box describing the dimensions of this block and any blocks stacked below it. Coordinate system: workspace coordinates.
- Implements
- Blockly.IBoundedElement#getBoundingRectangle
- Returns
-
non-null Blockly.utils.Rect
Object with coordinates of the bounding box.
getChildren
getChildren(ordered) returns Array of non-null Blockly.Block
Find all the blocks that are directly nested inside this one. Includes value and statement inputs, as well as any following statement. Excludes any connection on an output tab or any preceding statement. Blocks are optionally sorted by position; top to bottom.
Parameter |
|
---|---|
ordered |
Sort the list if true. |
- Inherited from
- Blockly.Block#getChildren
- Returns
-
Array of blocks.
getColour
getColour() returns string
Get the colour of a block.
- Returns
-
string
#RRGGBB string.
getColourBorder
getColourBorder() returns Object
Get the border colour(s) of a block.
- Deprecated
- Use style.colourTertiary. (2020 January 21)
- Returns
-
{colourDark, colourLight, colourBorder}
An object containing colour values for the border(s) of the block. If the block is using a style the colourBorder will be defined and equal to the tertiary colour of the style (#RRGGBB string). Otherwise the colourDark and colourLight attributes will be defined (#RRGGBB strings).
getColourSecondary
getColourSecondary() returns string
Get the secondary colour of a block.
- Returns
-
nullable string
#RRGGBB string.
getColourShadow
getColourShadow() returns string
Get the shadow colour of a block.
- Deprecated
- Use style.colourSecondary. (2020 January 21)
- Returns
-
nullable string
#RRGGBB string.
getColourTertiary
getColourTertiary() returns string
Get the tertiary colour of a block.
- Returns
-
nullable string
#RRGGBB string.
getCommentIcon
getCommentIcon() returns Blockly.Comment
Get the comment icon attached to this block, or null if the block has no comment.
- Returns
-
Blockly.Comment
The comment icon attached to this block, or null.
getCommentText
getCommentText() returns string
Returns the comment on this block (or null if there is no comment).
- Inherited from
- Blockly.Block#getCommentText
- Returns
-
Block's comment.
getConnections_
getConnections_(all) returns Array of non-null Blockly.RenderedConnection
Returns connections originating from this block.
Parameter |
|
---|---|
all |
boolean If true, return all connections even hidden ones. Otherwise, for a non-rendered block return an empty list, and for a collapsed block don't return inputs connections. |
- Returns
-
non-null Array of non-null Blockly.RenderedConnection
Array of connections.
getDescendants
getDescendants(ordered) returns Array of non-null Blockly.Block
Find all the blocks that are directly or indirectly nested inside this one. Includes this block in the list. Includes value and statement inputs, as well as any following statements. Excludes any connection on an output tab or any preceding statements. Blocks are optionally sorted by position; top to bottom.
Parameter |
|
---|---|
ordered |
Sort the list if true. |
- Inherited from
- Blockly.Block#getDescendants
- Returns
-
Flattened array of blocks.
getField
getField(name) returns Blockly.Field
Returns the named field from a block.
Parameter |
|
---|---|
name |
The name of the field. |
- Inherited from
- Blockly.Block#getField
- Returns
-
Named field, or null if field does not exist.
getFieldValue
getFieldValue(name) returns any type
Returns the language-neutral value of the given field.
Parameter |
|
---|---|
name |
The name of the field. |
- Inherited from
- Blockly.Block#getFieldValue
- Returns
-
Value of the field or null if field does not exist.
getFirstStatementConnection
getFirstStatementConnection() returns Blockly.Connection
Return the connection on the first statement input on this block, or null if there are none.
- Inherited from
- Blockly.Block#getFirstStatementConnection
- Returns
-
The first statement connection or null.
getHeightWidth
getHeightWidth() returns Object
Returns a bounding box describing the dimensions of this block and any blocks stacked below it.
- Returns
-
non-null {height: number, width: number}
Object with height and width properties in workspace units.
getHue
getHue() returns number
Get the HSV hue value of a block. Null if hue not set.
- Inherited from
- Blockly.Block#getHue
- Returns
-
Hue value (0-360).
getIcons
getIcons() returns Array
Returns a list of mutator, comment, and warning icons.
- Returns
-
non-null Array
List of icons.
getInheritedDisabled
getInheritedDisabled() returns boolean
Get whether the block is disabled or not due to parents. The block's own disabled property is not considered.
- Inherited from
- Blockly.Block#getInheritedDisabled
- Returns
-
True if disabled.
getInput
getInput(name) returns Blockly.Input
Fetches the named input object.
Parameter |
|
---|---|
name |
The name of the input. |
- Inherited from
- Blockly.Block#getInput
- Returns
-
The input object, or null if input does not exist.
getInputsInline
getInputsInline() returns boolean
Get whether value inputs are arranged horizontally or vertically.
- Inherited from
- Blockly.Block#getInputsInline
- Returns
-
True if inputs are horizontal.
getInputTargetBlock
getInputTargetBlock(name) returns Blockly.Block
Fetches the block attached to the named input.
Parameter |
|
---|---|
name |
The name of the input. |
- Inherited from
- Blockly.Block#getInputTargetBlock
- Returns
-
The attached value block, or null if the input is either disconnected or if the input does not exist.
getInputWithBlock
getInputWithBlock(block) returns Blockly.Input
Return the input that connects to the specified block.
Parameter |
|
---|---|
block |
A block connected to an input on this block. Value must not be null. |
- Inherited from
- Blockly.Block#getInputWithBlock
- Returns
-
The input that connects to the specified block.
getMatchingConnection
getMatchingConnection(otherBlock, conn) returns Blockly.RenderedConnection
Find the connection on this block that corresponds to the given connection on the other block. Used to match connections between a block and its insertion marker.
Parameter |
|
---|---|
otherBlock |
The other block to match against. Value must not be null. |
conn |
The other connection to match. Value must not be null. |
- Inherited from
- Blockly.BlockSvg#getMatchingConnection
- Returns
-
The matching connection on this block, or null.
getNextBlock
getNextBlock() returns Blockly.Block
Return the next statement block directly connected to this block.
- Inherited from
- Blockly.Block#getNextBlock
- Returns
-
The next statement block or null.
getOutputShape
getOutputShape() returns number
Get the block's output shape.
- Inherited from
- Blockly.Block#getOutputShape
- Returns
-
Value representing output shape if one exists.
getParent
getParent() returns Blockly.BlockSvg
Return the parent block or null if this block is at the top level.
- Inherited from
- Blockly.BlockSvg#getParent
- Returns
-
The block that holds the current block.
getPreviousBlock
getPreviousBlock() returns Blockly.Block
Returns the block connected to the previous connection.
- Inherited from
- Blockly.Block#getPreviousBlock
- Returns
-
The previous statement block or null.
getRelativeToSurfaceXY
getRelativeToSurfaceXY() returns Blockly.utils.Coordinate
Return the coordinates of the top-left corner of this block relative to the drawing surface's origin (0,0), in workspace units. If the block is on the workspace, (0, 0) is the origin of the workspace coordinate system. This does not change with workspace scale.
- Returns
-
non-null Blockly.utils.Coordinate
Object with .x and .y properties in workspace coordinates.
getRootBlock
getRootBlock() returns Blockly.BlockSvg
Return the top-most block in this block's tree. This will return itself if this block is at the top level.
- Inherited from
- Blockly.BlockSvg#getRootBlock
- Returns
-
The root block.
getStyleName
getStyleName() returns string
Get the name of the block style.
- Inherited from
- Blockly.Block#getStyleName
- Returns
-
Name of the block style.
getSurroundParent
getSurroundParent() returns Blockly.Block
Return the parent block that surrounds the current block, or null if this block has no surrounding block. A parent block might just be the previous statement, whereas the surrounding block is an if statement, while loop, etc.
- Inherited from
- Blockly.Block#getSurroundParent
- Returns
-
The block that surrounds the current block.
getSvgRoot
getSvgRoot() returns SVGGElement
Return the root node of the SVG or null if none exists.
- Returns
-
non-null SVGGElement
The root SVG node (probably a group).
getTooltip
getTooltip() returns string
Returns the tooltip text for this block.
- Inherited from
- Blockly.Block#getTooltip
- Returns
-
The tooltip text for this block.
getTopStackBlock
getTopStackBlock() returns Blockly.Block
Walk up from the given block up through the stack of blocks to find the top block of the sub stack. If we are nested in a statement input only find the top-most nested block. Do not go all the way to the root block.
- Inherited from
- Blockly.Block#getTopStackBlock
- Returns
-
The top block in a stack.
getVarModels
getVarModels() returns Array of non-null Blockly.VariableModel
Return all variables referenced by this block.
- Inherited from
- Blockly.Block#getVarModels
- Returns
-
List of variable models.
getVars
getVars() returns Array of string
Return all variables referenced by this block.
- Inherited from
- Blockly.Block#getVars
- Returns
-
List of variable names.
highlightShapeForInput
highlightShapeForInput(conn, add)
Visual effect to show that if the dragging block is dropped it will connect to this input.
Parameter |
|
---|---|
conn |
The connection on the input to highlight. |
add |
boolean True if highlighting should be added. |
initModel
initModel()
Call initModel on all fields on the block. May be called more than once. Either initModel or initSvg must be called after creating a block and before the first interaction with it. Interactions include UI actions (e.g. clicking and dragging) and firing events (e.g. create, delete, and change).
- Inherited from
- Blockly.Block#initModel
initSvg
initSvg()
Create and initialize the SVG representation of the block. May be called more than once.
isCollapsed
isCollapsed() returns boolean
Get whether the block is collapsed or not.
- Inherited from
- Blockly.Block#isCollapsed
- Returns
-
True if collapsed.
isDeletable
isDeletable() returns boolean
Get whether this block is deletable or not.
- Inherited from
- Blockly.Block#isDeletable
- Implements
- Blockly.ICopyable#isDeletable
- Returns
-
True if deletable.
isDisposed
isDisposed() returns boolean
Returns if this block has been disposed of / deleted.
- Inherited from
- Blockly.Block#isDisposed
- Returns
-
True if this block has been disposed of / deleted.
isDuplicatable
isDuplicatable() returns boolean
Get whether is block is duplicatable or not. If duplicating this block and descendants will put this block over the workspace's capacity this block is not duplicatable. If duplicating this block and descendants will put any type over their maxInstances this block is not duplicatable.
- Inherited from
- Blockly.Block#isDuplicatable
- Returns
-
True if duplicatable.
isEditable
isEditable() returns boolean
Get whether this block is editable or not.
- Inherited from
- Blockly.Block#isEditable
- Returns
-
True if editable.
isEnabled
isEnabled() returns boolean
Get whether this block is enabled or not.
- Inherited from
- Blockly.Block#isEnabled
- Returns
-
True if enabled.
isInsertionMarker
isInsertionMarker() returns boolean
Get whether this block is an insertion marker block or not.
- Inherited from
- Blockly.Block#isInsertionMarker
- Returns
-
True if an insertion marker.
isMovable
isMovable() returns boolean
Get whether this block is movable or not.
- Inherited from
- Blockly.Block#isMovable
- Implements
- Blockly.ICopyable#isMovable
- Returns
-
True if movable.
isShadow
isShadow() returns boolean
Get whether this block is a shadow block or not.
- Inherited from
- Blockly.Block#isShadow
- Returns
-
True if a shadow.
jsonInit
jsonInit(json)
Initialize this block using a cross-platform, internationalization-friendly JSON description.
Parameter |
|
---|---|
json |
Structured data describing the block. Value must not be null. |
- Inherited from
- Blockly.Block#jsonInit
lastConnectionInStack
lastConnectionInStack() returns Blockly.RenderedConnection
Walks down a stack of blocks and finds the last next connection on the stack.
- Inherited from
- Blockly.BlockSvg#lastConnectionInStack
- Returns
-
The last next connection on the stack, or null.
makeConnection_
makeConnection_(type) returns Blockly.RenderedConnection
Create a connection of the specified type.
Parameter |
|
---|---|
type |
number The type of the connection to create. |
- Returns
-
non-null Blockly.RenderedConnection
A new connection of the specified type.
markDirty
markDirty()
Notify every input on this block to mark its fields as dirty. A dirty field is a field that needs to be re-rendered.
mixin
mixin(mixinObj, opt_disableCheck)
Add key/values from mixinObj to this block object. By default, this method will check that the keys in mixinObj will not overwrite existing values in the block, including prototype values. This provides some insurance against mixin / extension incompatibilities with future block features. This check can be disabled by passing true as the second argument.
Parameter |
|
---|---|
mixinObj |
The key/values pairs to add to this block object. Value must not be null. |
opt_disableCheck |
Optional Option flag to disable overwrite checks. |
- Inherited from
- Blockly.Block#mixin
moveBy
moveBy(dx, dy)
Move a block by a relative offset.
Parameter |
|
---|---|
dx |
number Horizontal offset in workspace units. |
dy |
number Vertical offset in workspace units. |
moveConnections
moveConnections(dx, dy)
Move the connections for this block and all blocks attached under it. Also update any attached bubbles.
Parameter |
|
---|---|
dx |
number Horizontal offset from current location, in workspace units. |
dy |
number Vertical offset from current location, in workspace units. |
moveDuringDrag
moveDuringDrag(newLoc)
Move this block during a drag, taking into account whether we are using a drag surface to translate blocks. This block must be a top-level block.
Parameter |
|
---|---|
newLoc |
The location to translate to, in workspace coordinates. Value must not be null. |
moveInputBefore
moveInputBefore(name, refName)
Move a named input to a different location on this block.
Parameter |
|
---|---|
name |
The name of the input to move. |
refName |
Name of input that should be after the moved input, or null to be the input at the end. Value may be null. |
- Inherited from
- Blockly.Block#moveInputBefore
moveNumberedInputBefore
moveNumberedInputBefore(inputIndex, refIndex)
Move a numbered input to a different location on this block.
Parameter |
|
---|---|
inputIndex |
number Index of the input to move. |
refIndex |
number Index of input that should be after the moved input. |
moveOffDragSurface
moveOffDragSurface(newXY)
Move this block back to the workspace block canvas. Generally should be called at the same time as setDragging_(false). Does nothing if useDragSurface_ is false.
Parameter |
|
---|---|
newXY |
The position the block should take on on the workspace canvas, in workspace coordinates. Value must not be null. |
moveTo
moveTo(xy)
Move a block to a position.
Parameter |
|
---|---|
xy |
The position to move to in workspace units. |
moveToDragSurface
moveToDragSurface()
Move this block to its workspace's drag surface, accounting for positioning. Generally should be called at the same time as setDragging_(true). Does nothing if useDragSurface_ is false.
positionNearConnection
positionNearConnection(sourceConnection, targetConnection)
Position a block so that it doesn't move the target block when connected. The block to position is usually either the first block in a dragged stack or an insertion marker.
Parameter |
|
---|---|
sourceConnection |
The connection on the moving block's stack. Value must not be null. |
targetConnection |
The connection that should stay stationary as this block is positioned. Value must not be null. |
removeInput
removeInput(name, opt_quiet) returns boolean
Remove an input from this block.
Parameter |
|
---|---|
name |
string The name of the input. |
opt_quiet |
Optional boolean True to prevent error if input is not present. |
- Throws
-
Error
if the input is not present and opt_quiet is not true. - Returns
-
boolean
True if operation succeeds, false if input is not present and opt_quiet is true
removeSelect
removeSelect()
Unselect this block. Remove its highlighting.
renameVarById
renameVarById(oldId, newId)
Notification that a variable is renaming. If the ID matches one of this block's variables, rename it.
Parameter |
|
---|---|
oldId |
ID of variable to rename. |
newId |
ID of new variable. May be the same as oldId, but with an updated name. |
- Inherited from
- Blockly.Block#renameVarById
render
render(opt_bubble)
Lays out and reflows a block based on its contents and settings.
Parameter |
|
---|---|
opt_bubble |
Optional boolean If false, just render this block. If true, also render block's parent, grandparent, etc. Defaults to true. |
scheduleSnapAndBump
scheduleSnapAndBump()
Schedule snapping to grid and bumping neighbours to occur after a brief delay.
select
select()
Select this block. Highlight it visually.
- Implements
- Blockly.ICopyable#select
setCollapsed
setCollapsed(collapsed)
Set whether the block is collapsed or not.
Parameter |
|
---|---|
collapsed |
boolean True if collapsed. |
setColour
setColour(colour)
Change the colour of a block.
Parameter |
|
---|---|
colour |
(number or string) HSV hue value, or #RRGGBB string. |
setCommentText
setCommentText(text)
Set this block's comment text.
Parameter |
|
---|---|
text |
string The text, or null to delete. Value may be null. |
setConnectionTracking
setConnectionTracking(track)
Sets whether this block's connections are tracked in the database or not.
Used by the deserializer to be more efficient. Setting a connection's tracked_ value to false keeps it from adding itself to the db when it gets its first moveTo call, saving expensive ops for later.
Parameter |
|
---|---|
track |
boolean If true, start tracking. If false, stop tracking. |
setCursorSvg
setCursorSvg(cursorSvg)
Add the cursor svg to this block's svg group.
Parameter |
|
---|---|
cursorSvg |
SVGElement The svg root of the cursor to be added to the block svg group. |
- Implements
- Blockly.IASTNodeLocationSvg#setCursorSvg
setDeletable
setDeletable(deletable)
Set whether this block is deletable or not.
Parameter |
|
---|---|
deletable |
True if deletable. |
- Inherited from
- Blockly.Block#setDeletable
setDeleteStyle
setDeleteStyle(enable)
Update the cursor over this block by adding or removing a class.
Parameter |
|
---|---|
enable |
boolean True if the delete cursor should be shown, false otherwise. |
setDragging
setDragging(adding)
Recursively adds or removes the dragging class to this node and its children.
Parameter |
|
---|---|
adding |
boolean True if adding, false if removing. |
setEditable
setEditable(editable)
Set whether this block is editable or not.
Parameter |
|
---|---|
editable |
boolean True if editable. |
setEnabled
setEnabled(enabled)
Set whether the block is enabled or not.
Parameter |
|
---|---|
enabled |
boolean True if enabled. |
setFieldValue
setFieldValue(newValue, name)
Sets the value of the given field for this block.
Parameter |
|
---|---|
newValue |
The value to set. |
name |
The name of the field to set the value of. Value must not be null. |
- Inherited from
- Blockly.Block#setFieldValue
setHelpUrl
setHelpUrl(url)
Set the URL of this block's help page.
Parameter |
|
---|---|
url |
URL string for block help, or function that returns a URL. Null for no help. |
- Inherited from
- Blockly.Block#setHelpUrl
setHighlighted
setHighlighted(highlighted)
Set whether the block is highlighted or not. Block highlighting is often used to visually mark blocks currently being executed.
Parameter |
|
---|---|
highlighted |
boolean True if highlighted. |
setInputsInline
setInputsInline(newBoolean)
Set whether value inputs are arranged horizontally or vertically.
Parameter |
|
---|---|
newBoolean |
boolean True if inputs are horizontal. |
setInsertionMarker
setInsertionMarker(insertionMarker)
Set whether this block is an insertion marker block or not. Once set this cannot be unset.
Parameter |
|
---|---|
insertionMarker |
boolean True if an insertion marker. |
setMarkerSvg
setMarkerSvg(markerSvg)
Add the marker svg to this block's svg group.
Parameter |
|
---|---|
markerSvg |
SVGElement The svg root of the marker to be added to the block svg group. |
- Implements
- Blockly.IASTNodeLocationSvg#setMarkerSvg
setMovable
setMovable(movable)
Set whether this block is movable or not.
Parameter |
|
---|---|
movable |
boolean True if movable. |
setMutator
setMutator(mutator)
Give this block a mutator dialog.
Parameter |
|
---|---|
mutator |
A mutator dialog instance or null to remove. |
setNextStatement
setNextStatement(newBoolean, opt_check)
Set whether another block can chain onto the bottom of this block.
Parameter |
|
---|---|
newBoolean |
boolean True if there can be a next statement. |
opt_check |
Optional (string, Array of string, or null) Statement type or list of statement types. Null/undefined if any type could be connected. |
setOnChange
setOnChange(onchangeFn)
Sets a callback function to use whenever the block's parent workspace changes, replacing any prior onchange handler. This is usually only called from the constructor, the block type initializer function, or an extension initializer function.
Parameter |
|
---|---|
onchangeFn |
The callback to call when the block's workspace changes. |
- Inherited from
- Blockly.Block#setOnChange
- Throws
-
if onchangeFn is not falsey and not a function.
setOutput
setOutput(newBoolean, opt_check)
Set whether this block returns a value.
Parameter |
|
---|---|
newBoolean |
boolean True if there is an output. |
opt_check |
Optional (string, Array of string, or null) Returned type or list of returned types. Null or undefined if any type could be returned (e.g. variable get). |
setOutputShape
setOutputShape(outputShape)
Set the block's output shape.
Parameter |
|
---|---|
outputShape |
Value representing an output shape. Value may be null. |
- Inherited from
- Blockly.Block#setOutputShape
setParent
setParent(newParent)
Set parent of this block to be a new block or null.
Parameter |
|
---|---|
newParent |
New parent block. |
- Inherited from
- Blockly.BlockSvg#setParent
setPreviousStatement
setPreviousStatement(newBoolean, opt_check)
Set whether this block can chain onto the bottom of another block.
Parameter |
|
---|---|
newBoolean |
boolean True if there can be a previous statement. |
opt_check |
Optional (string, Array of string, or null) Statement type or list of statement types. Null/undefined if any type could be connected. |
setShadow
setShadow(shadow)
Set whether this block is a shadow block or not.
Parameter |
|
---|---|
shadow |
boolean True if a shadow. |
setStyle
setStyle(blockStyleName)
Set the style and colour values of a block.
Parameter |
|
---|---|
blockStyleName |
string Name of the block style |
- Throws
-
Error
if the block style does not exist.
setTooltip
setTooltip(newTip)
Sets the tooltip for this block.
Parameter |
|
---|---|
newTip |
The text for the tooltip, a function that returns the text for the tooltip, or a parent object whose tooltip will be used. To not display a tooltip pass the empty string. Value must not be null. |
- Inherited from
- Blockly.Block#setTooltip
setWarningText
setWarningText(text, opt_id)
Set this block's warning text.
Parameter |
|
---|---|
text |
string The text, or null to delete. Value may be null. |
opt_id |
Optional string An optional ID for the warning text to be able to maintain multiple warnings. |
showContextMenu
showContextMenu(e)
Show the context menu for this block.
Parameter |
|
---|---|
e |
Event Mouse event. Value must not be null. |
showHelp
showHelp()
Load the block's help page in a new window.
snapToGrid
snapToGrid()
Snap this block to the nearest grid point.
tab
tab(start, forward)
Open the next (or previous) FieldTextInput.
Parameter |
|
---|---|
start |
Current field. Value must not be null. |
forward |
boolean If true go forward, otherwise backward. |
toCopyData
toCopyData() returns Blockly.ICopyable.CopyData
Encode a block for copying.
- Implements
- Blockly.ICopyable#toCopyData
- Returns
-
nullable Blockly.ICopyable.CopyData
Copy metadata, or null if the block is an insertion marker.
toDevString
toDevString() returns string
This method returns a string describing this Block in developer terms (type name and ID; English only).
Intended to on be used in console logs and errors. If you need a string that uses the user's native language (including block text, field values, and child blocks), use toString().
- Inherited from
- Blockly.Block#toDevString
- Returns
-
The description.
toString
toString(opt_maxLength, opt_emptyToken) returns string
Create a human-readable text representation of this block and any children.
Parameter |
|
---|---|
opt_maxLength |
Optional Truncate the string to this length. |
opt_emptyToken |
Optional The placeholder string used to denote an empty field. If not specified, '?' is used. |
- Inherited from
- Blockly.Block#toString
- Returns
-
Text of block.
translate
translate(x, y)
Transforms a block by setting the translation on the transform attribute of the block's SVG.
Parameter |
|
---|---|
x |
number The x coordinate of the translation in workspace units. |
y |
number The y coordinate of the translation in workspace units. |
unplug
unplug(opt_healStack)
Unplug this block from its superior block. If this block is a statement, optionally reconnect the block underneath with the block on top.
Parameter |
|
---|---|
opt_healStack |
Optional Disconnect child statement and reconnect stack. Defaults to false. |
- Inherited from
- Blockly.Block#unplug
unselect
unselect()
Unselect this block. Remove its highlighting.
- Implements
- Blockly.ICopyable#unselect
updateDisabled
updateDisabled()
Enable or disable a block.
updateMarkers_
updateMarkers_()
Redraw any attached marker or cursor svgs if needed.
updateVarName
updateVarName(variable)
Notification that a variable is renaming but keeping the same ID. If the variable is in use on this block, rerender to show the new name.
Parameter |
|
---|---|
variable |
The variable being renamed. Value must not be null. |
- Inherited from
- Blockly.Block#updateVarName