Skip to main content

Class: WorkspaceSvg

Defined in: packages/blockly/core/workspace_svg.ts:98

Class for a workspace. This is an onscreen area with optional trashcan, scrollbars, bubbles, and dragging.

Extends​

Implements​

Properties index​

PropertyDescription
SCAN_ANGLEAngle away from the horizontal to sweep for blocks. Order of execution is generally top to bottom, but a small angle changes the scan to give a bit of a left to right bias (reversed in RTL). Units are in degrees. See: https://tvtropes.org/pmwiki/pmwiki.php/Main/DiagonalBilling
id-
options-
RTL-
horizontalLayout-
toolboxPosition-
MAX_UNDOMaximum number of undo events in stack. 0 turns off undo, Infinity sets it to unlimited.
connectionDBListSet of databases for rapid lookup of connection locations.
connectionChecker-
undoStack_-
redoStack_-
renderedThe render status of an SVG workspace. Returns false for headless workspaces and true for instances of WorkspaceSvg.
scrollXCurrent horizontal scrolling offset in pixel units, relative to the workspace origin.
scrollYCurrent vertical scrolling offset in pixel units, relative to the workspace origin.
startScrollXHorizontal scroll value when scrolling started in pixel units.
startScrollYVertical scroll value when scrolling started in pixel units.
scaleCurrent scale.
trashcanThe workspace's trashcan (if any).
scrollbarThis workspace's scrollbars, if they exist.
configureContextMenuDevelopers may define this function to add custom menu options to the workspace's context menu or edit the workspace-created set of menu options.
themeManager_-
svgGroup_-
svgBackground_-
svgBlockCanvas_-
svgBubbleCanvas_-
zoomControls_-

Methods index​

MethodDescription
sortByOriginSorts bounded elements on the workspace by their relative position, top to bottom (with slight LTR or RTL bias).
addTypedBlockAdd a block to the list of blocks keyed by type.
removeTypedBlockRemove a block from the list of blocks keyed by type.
getBlocksByTypeFinds the blocks with the associated type and returns them. Blocks are optionally sorted by position; top to bottom (with slight LTR or RTL bias).
remainingCapacityThe number of blocks that may be added to the workspace before reaching the maxBlocks.
remainingCapacityOfTypeThe number of blocks of the given type that may be added to the workspace before reaching the maxInstances allowed for that type.
isCapacityAvailableCheck if there is remaining capacity for blocks of the given counts to be created. If the total number of blocks represented by the map is more than the total remaining capacity, it returns false. If a type count is more than the remaining capacity for that type, it returns false.
hasBlockLimitsChecks if the workspace has any limits on the maximum number of blocks, or the maximum number of blocks of specific types.
undoUndo or redo the previous action.
redoRedoes the previous action.
clearUndoClear the undo/redo stacks.
addChangeListenerWhen something in this workspace changes, call a function. Note that there may be a few recent events already on the stack. Thus the new change listener might be called with events that occurred a few milliseconds before the change listener was added.
removeChangeListenerStop listening for this workspace's changes.
fireChangeListenerFire a change event.
allInputsFilledChecks whether all value and statement inputs in the workspace are filled with blocks.
getPotentialVariableMapReturn the variable map that contains "potential" variables. These exist in the flyout but not in the workspace.
getVariableMapReturn the map of all variables on the workspace.
getProcedureMapReturns the map of all procedures on the workpace.
getByIdFind the workspace with the specified ID.
getAllFind all workspaces.
getVariableMapClass-
isReadOnlyReturns whether or not this workspace is in readonly mode.
getMetricsManagerGets the metrics manager for this workspace.
getComponentManagerGets the component manager for this workspace.
getRendererGet the block renderer attached to this workspace.
getThemeGet the workspace theme object.
setThemeSet the workspace theme object. If no theme is passed, default to the Classic theme.
refreshThemeRefresh all blocks on the workspace after a theme update.
getInverseScreenCTMGetter for the inverted screen CTM.
updateInverseScreenCTMMark the inverse screen CTM as dirty.
isVisibleGetter for isVisible
getSvgGroupReturns the SVG group for the workspace.
setResizeHandlerWrapperSave resize handler data so we can delete it later in dispose.
setInitialAriaContextSets Aria labels, roles, etc. for the workspace depending on the type of workspace it is.
createDomCreate the workspace DOM elements.
disposeDispose of this workspace. Unlink from all DOM elements to prevent memory leaks.
copyOptionsForFlyoutCreates a new set of options from this workspace's options with just the values that are relevant to a flyout.
getFlyoutGetter for the flyout associated with this workspace. This flyout may be owned by either the toolbox or the workspace, depending on toolbox configuration. It will be null if there is no flyout.
getToolboxGetter for the toolbox associated with this workspace, if one exists.
resizeResize and reposition all of the workspace chrome (toolbox, trash, scrollbars etc.) This should be called when something changes that requires recalculating dimensions and positions of the trash, zoom, toolbox, etc. (e.g. window resize).
getCanvasGet the SVG element that forms the drawing surface.
getBubbleCanvasGet the SVG element that forms the bubble surface.
getParentSvgGet the SVG element that contains this workspace. Note: We assume this is only called after the workspace has been injected into the DOM.
translateTranslate this workspace to new coordinates.
getWidthReturns the horizontal offset of the workspace. Intended for LTR/RTL compatibility in XML.
setVisibleToggles the visibility of the workspace. Currently only intended for main workspace.
renderRender all blocks in workspace.
highlightBlockHighlight or unhighlight a block in the workspace. Block highlighting is often used to visually mark blocks currently being executed.
recordDragTargetsMake a list of all the delete areas for this workspace.
newBlockObtain a newly created block.
newCommentObtain a newly created comment.
getDragTargetReturns the drag target at the given point.
startDragStart tracking a drag of an object on this workspace.
moveDragTrack a drag of an object on this workspace.
isDraggingReturns true iff the user is currently engaged in a drag gesture, or if a keyboard-initated move is in progress.
isDraggableIs this workspace draggable?
isMovableIs this workspace movable?
isMovableHorizontallyIs this workspace movable horizontally?
isMovableVerticallyIs this workspace movable vertically?
getBlocksBoundingBoxCalculate the bounding box for the blocks on the workspace. Coordinate system: workspace coordinates.
cleanUpClean up the workspace by ordering all the blocks in a column such that none overlap.
updateToolboxModify the block tree on the existing toolbox.
markFocusedMark this workspace as the currently focused main workspace.
zoomZooms the workspace in or out relative to/centered on the given (x, y) coordinate.
zoomCenterZooming the blocks centered in the center of view with zooming in or out.
zoomToFitZoom the blocks to fit in the workspace if possible.
scrollCenterCenter the workspace.
centerOnBlockScroll the workspace to center on the given block. If the block has other blocks stacked below it, the workspace will be centered on the stack, unless blockOnly is true.
setScaleSet the workspace's zoom factor.
getScaleGet the workspace's zoom factor.
getAbsoluteScaleReturns the absolute scale of the workspace.
scrollScroll the workspace to a specified offset (in pixels), keeping in the workspace bounds. See comment on workspaceSvg.scrollX for more detail on the meaning of these values.
getBlockByIdFind the block on this workspace with the specified ID.
getAllBlocksFind all blocks in workspace. Blocks are optionally sorted by position; top to bottom (with slight LTR or RTL bias).
getTopBlocksFinds the top-level blocks and returns them. Blocks are optionally sorted by position; top to bottom (with slight LTR or RTL bias).
addTopBlockAdds a block to the list of top blocks.
removeTopBlockRemoves a block from the list of top blocks.
addTopCommentAdds a comment to the list of top comments.
removeTopCommentRemoves a comment from the list of top comments.
getTopCommentsReturns a list of comments on this workspace.
getCommentByIdReturns the workspace comment with the given ID, if any.
getRootWorkspaceReturns the root workspace of this workspace if the workspace has parent(s).
addTopBoundedElementAdds a bounded element to the list of top bounded elements.
removeTopBoundedElementRemoves a bounded element from the list of top bounded elements.
getTopBoundedElementsFinds the top-level bounded elements and returns them.
setResizesEnabledUpdate whether this workspace has resizes enabled. If enabled, workspace will resize when appropriate. If disabled, workspace will not resize until re-enabled. Use to avoid resizing during a batch operation, for performance.
clearDispose of all blocks in workspace, with an optimization to prevent resizes.
registerButtonCallbackRegister a callback function associated with a given key, for clicks on buttons and labels in the flyout. For instance, a button specified by the XML should be matched by a call to registerButtonCallback("CREATE_VARIABLE", yourCallbackFunction).
getButtonCallbackGet the callback function associated with a given key, for clicks on buttons and labels in the flyout.
removeButtonCallbackRemove a callback for a click on a button in the flyout.
registerToolboxCategoryCallbackRegister a callback function associated with a given key, for populating custom toolbox categories in this workspace. See the variable and procedure categories as an example.
getToolboxCategoryCallbackGet the callback function associated with a given key, for populating custom toolbox categories in this workspace.
removeToolboxCategoryCallbackRemove a callback for a click on a custom category's name in the toolbox.
getAudioManagerGet the audio manager for this workspace.
getGridGet the grid object for this workspace, or null if there is none.
hideChaffClose tooltips, context menus, dropdown selections, etc.
hideComponentsHide any autohideable components (like flyout, trashcan, and any user-registered components).
addClassAdds a CSS class to the workspace.
removeClassRemoves a CSS class from the workspace.
setIsReadOnlySets whether or not this workspace is in readonly mode.
getFocusableElementSee IFocusableNode.getFocusableElement.
getFocusableTreeSee IFocusableNode.getFocusableTree.
onNodeFocusSee IFocusableNode.onNodeFocus.
onNodeBlurSee IFocusableNode.onNodeBlur.
canBeFocusedSee IFocusableNode.canBeFocused.
getRootFocusableNodeSee IFocusableTree.getRootFocusableNode.
getRestoredFocusableNodeSee IFocusableTree.getRestoredFocusableNode.
getWorkspaceFocusTargetReturns the focusable node representing this workspace as a whole, or null for workspaces without one (flyouts and mutators).
getNestedTreesSee IFocusableTree.getNestedTrees.
lookUpFocusableNodeSee IFocusableTree.lookUpFocusableNode.
onTreeFocusSee IFocusableTree.onTreeFocus.
onTreeBlurSee IFocusableTree.onTreeBlur.
performActionHandles the user acting on this workspace via keyboard navigation by prompting them to use the arrow keys (instead of Enter) to navigate.
getNavigatorReturns an object responsible for coordinating movement of focus between items on this workspace in response to keyboard navigation commands.
setNavigatorSets the Navigator instance used by this workspace.

Constructors​

Constructor​

new WorkspaceSvg(options): WorkspaceSvg;

Defined in: packages/blockly/core/workspace_svg.ts:368

Parameters​

ParameterTypeDescription
optionsOptionsDictionary of options.

Returns​

WorkspaceSvg

Overrides​

Workspace.constructor

Properties​

SCAN_ANGLE​

static SCAN_ANGLE: number = 3;

Defined in: packages/blockly/core/workspace.ts:49

Angle away from the horizontal to sweep for blocks. Order of execution is generally top to bottom, but a small angle changes the scan to give a bit of a left to right bias (reversed in RTL). Units are in degrees. See: https://tvtropes.org/pmwiki/pmwiki.php/Main/DiagonalBilling

Inherited from​

Workspace.SCAN_ANGLE


id​

id: string;

Defined in: packages/blockly/core/workspace.ts:50

Inherited from​

Workspace.id


options​

options: Options;

Defined in: packages/blockly/core/workspace.ts:51

Inherited from​

Workspace.options


RTL​

RTL: boolean;

Defined in: packages/blockly/core/workspace.ts:52

Inherited from​

Workspace.RTL


horizontalLayout​

horizontalLayout: boolean;

Defined in: packages/blockly/core/workspace.ts:53

Inherited from​

Workspace.horizontalLayout


toolboxPosition​

toolboxPosition: Position;

Defined in: packages/blockly/core/workspace.ts:54

Inherited from​

Workspace.toolboxPosition


MAX_UNDO​

MAX_UNDO: number = 1024;

Defined in: packages/blockly/core/workspace.ts:97

Maximum number of undo events in stack. 0 turns off undo, Infinity sets it to unlimited.

Inherited from​

Workspace.MAX_UNDO


connectionDBList​

connectionDBList: ConnectionDB[] = [];

Defined in: packages/blockly/core/workspace.ts:100

Set of databases for rapid lookup of connection locations.

Inherited from​

Workspace.connectionDBList


connectionChecker​

connectionChecker: IConnectionChecker;

Defined in: packages/blockly/core/workspace.ts:101

Inherited from​

Workspace.connectionChecker


undoStack_​

protected undoStack_: Abstract[] = [];

Defined in: packages/blockly/core/workspace.ts:107

Inherited from​

Workspace.undoStack_


redoStack_​

protected redoStack_: Abstract[] = [];

Defined in: packages/blockly/core/workspace.ts:108

Inherited from​

Workspace.redoStack_


rendered​

rendered: boolean = true;

Defined in: packages/blockly/core/workspace_svg.ts:113

The render status of an SVG workspace. Returns false for headless workspaces and true for instances of WorkspaceSvg.

Overrides​

Workspace.rendered


scrollX​

scrollX: number = 0;

Defined in: packages/blockly/core/workspace_svg.ts:157

Current horizontal scrolling offset in pixel units, relative to the workspace origin.

It is useful to think about a view, and a canvas moving beneath that view. As the canvas moves right, this value becomes more positive, and the view is now "seeing" the left side of the canvas. As the canvas moves left, this value becomes more negative, and the view is now "seeing" the right side of the canvas.

The confusing thing about this value is that it does not, and must not include the absoluteLeft offset. This is because it is used to calculate the viewLeft value.

The viewLeft is relative to the workspace origin (although in pixel units). The workspace origin is the top-left corner of the workspace (at least when it is enabled). It is shifted from the top-left of the blocklyDiv so as not to be beneath the toolbox.

When the workspace is enabled the viewLeft and workspace origin are at the same X location. As the canvas slides towards the right beneath the view this value (scrollX) becomes more positive, and the viewLeft becomes more negative relative to the workspace origin (imagine the workspace origin as a dot on the canvas sliding to the right as the canvas moves).

So if the scrollX were to include the absoluteLeft this would in a way "unshift" the workspace origin. This means that the viewLeft would be representing the left edge of the blocklyDiv, rather than the left edge of the workspace.


scrollY​

scrollY: number = 0;

Defined in: packages/blockly/core/workspace_svg.ts:189

Current vertical scrolling offset in pixel units, relative to the workspace origin.

It is useful to think about a view, and a canvas moving beneath that view. As the canvas moves down, this value becomes more positive, and the view is now "seeing" the upper part of the canvas. As the canvas moves up, this value becomes more negative, and the view is "seeing" the lower part of the canvas.

This confusing thing about this value is that it does not, and must not include the absoluteTop offset. This is because it is used to calculate the viewTop value.

The viewTop is relative to the workspace origin (although in pixel units). The workspace origin is the top-left corner of the workspace (at least when it is enabled). It is shifted from the top-left of the blocklyDiv so as not to be beneath the toolbox.

When the workspace is enabled the viewTop and workspace origin are at the same Y location. As the canvas slides towards the bottom this value (scrollY) becomes more positive, and the viewTop becomes more negative relative to the workspace origin (image in the workspace origin as a dot on the canvas sliding downwards as the canvas moves).

So if the scrollY were to include the absoluteTop this would in a way "unshift" the workspace origin. This means that the viewTop would be representing the top edge of the blocklyDiv, rather than the top edge of the workspace.


startScrollX​

startScrollX: number = 0;

Defined in: packages/blockly/core/workspace_svg.ts:192

Horizontal scroll value when scrolling started in pixel units.


startScrollY​

startScrollY: number = 0;

Defined in: packages/blockly/core/workspace_svg.ts:195

Vertical scroll value when scrolling started in pixel units.


scale​

scale: number = 1;

Defined in: packages/blockly/core/workspace_svg.ts:198

Current scale.


trashcan​

trashcan: Trashcan | null = null;

Defined in: packages/blockly/core/workspace_svg.ts:210

The workspace's trashcan (if any).


scrollbar​

scrollbar: ScrollbarPair | null = null;

Defined in: packages/blockly/core/workspace_svg.ts:213

This workspace's scrollbars, if they exist.


configureContextMenu​

configureContextMenu: ((menuOptions, e) => void) | null = null;

Defined in: packages/blockly/core/workspace_svg.ts:254

Developers may define this function to add custom menu options to the workspace's context menu or edit the workspace-created set of menu options.

Param​

options

List of menu options to add to.

Param​

e

The right-click event that triggered the context menu.


themeManager_​

protected themeManager_: ThemeManager;

Defined in: packages/blockly/core/workspace_svg.ts:305


svgGroup_​

svgGroup_: SVGElement;

Defined in: packages/blockly/core/workspace_svg.ts:320


svgBackground_​

svgBackground_: SVGElement;

Defined in: packages/blockly/core/workspace_svg.ts:322


svgBlockCanvas_​

svgBlockCanvas_: SVGElement;

Defined in: packages/blockly/core/workspace_svg.ts:324


svgBubbleCanvas_​

svgBubbleCanvas_: SVGElement;

Defined in: packages/blockly/core/workspace_svg.ts:326


zoomControls_​

zoomControls_: ZoomControls | null = null;

Defined in: packages/blockly/core/workspace_svg.ts:327

Accessors​

isFlyout​

Get Signature​

get isFlyout(): boolean;

Defined in: packages/blockly/core/workspace.ts:69

Is this workspace the surface for a flyout?

Returns​

boolean

Inherited from​

Workspace.isFlyout


isMutator​

Get Signature​

get isMutator(): boolean;

Defined in: packages/blockly/core/workspace.ts:81

Is this workspace the surface for a mutator?

Returns​

boolean

Inherited from​

Workspace.isMutator

Methods​

sortByOrigin()​

protected sortByOrigin(a, b): number;

Defined in: packages/blockly/core/workspace.ts:201

Sorts bounded elements on the workspace by their relative position, top to bottom (with slight LTR or RTL bias).

Parameters​

ParameterTypeDescription
aIBoundedElementThe first element to sort.
bIBoundedElementThe second elment to sort.

Returns​

number

-1, 0 or 1 depending on the sort order.

Inherited from​

Workspace.sortByOrigin


addTypedBlock()​

addTypedBlock(block): void;

Defined in: packages/blockly/core/workspace.ts:250

Add a block to the list of blocks keyed by type.

Parameters​

ParameterTypeDescription
blockBlockBlock to add.

Returns​

void

Inherited from​

Workspace.addTypedBlock


removeTypedBlock()​

removeTypedBlock(block): void;

Defined in: packages/blockly/core/workspace.ts:262

Remove a block from the list of blocks keyed by type.

Parameters​

ParameterTypeDescription
blockBlockBlock to remove.

Returns​

void

Inherited from​

Workspace.removeTypedBlock


getBlocksByType()​

getBlocksByType(type, ordered?): Block[];

Defined in: packages/blockly/core/workspace.ts:277

Finds the blocks with the associated type and returns them. Blocks are optionally sorted by position; top to bottom (with slight LTR or RTL bias).

Parameters​

ParameterTypeDefault valueDescription
typestringundefinedThe type of block to search for.
orderedbooleanfalseSort the list if true.

Returns​

Block[]

The blocks of the given type.

Inherited from​

Workspace.getBlocksByType


remainingCapacity()​

remainingCapacity(): number;

Defined in: packages/blockly/core/workspace.ts:454

The number of blocks that may be added to the workspace before reaching the maxBlocks.

Returns​

number

Number of blocks left.

Inherited from​

Workspace.remainingCapacity


remainingCapacityOfType()​

remainingCapacityOfType(type): number;

Defined in: packages/blockly/core/workspace.ts:469

The number of blocks of the given type that may be added to the workspace before reaching the maxInstances allowed for that type.

Parameters​

ParameterTypeDescription
typestringType of block to return capacity for.

Returns​

number

Number of blocks of type left.

Inherited from​

Workspace.remainingCapacityOfType


isCapacityAvailable()​

isCapacityAvailable(typeCountsMap): boolean;

Defined in: packages/blockly/core/workspace.ts:492

Check if there is remaining capacity for blocks of the given counts to be created. If the total number of blocks represented by the map is more than the total remaining capacity, it returns false. If a type count is more than the remaining capacity for that type, it returns false.

Parameters​

ParameterTypeDescription
typeCountsMap{ [key: string]: number; }A map of types to counts (usually representing blocks to be created).

Returns​

boolean

True if there is capacity for the given map, false otherwise.

Inherited from​

Workspace.isCapacityAvailable


hasBlockLimits()​

hasBlockLimits(): boolean;

Defined in: packages/blockly/core/workspace.ts:515

Checks if the workspace has any limits on the maximum number of blocks, or the maximum number of blocks of specific types.

Returns​

boolean

True if it has block limits, false otherwise.

Inherited from​

Workspace.hasBlockLimits


undo()​

undo(redo?): void;

Defined in: packages/blockly/core/workspace.ts:544

Undo or redo the previous action.

Parameters​

ParameterTypeDefault valueDescription
redobooleanfalseFalse if undo, true if redo.

Returns​

void

Inherited from​

Workspace.undo


redo()​

redo(): void;

Defined in: packages/blockly/core/workspace.ts:581

Redoes the previous action.

Returns​

void

Inherited from​

Workspace.redo


clearUndo()​

clearUndo(): void;

Defined in: packages/blockly/core/workspace.ts:586

Clear the undo/redo stacks.

Returns​

void

Inherited from​

Workspace.clearUndo


addChangeListener()​

addChangeListener(func): (e) => void;

Defined in: packages/blockly/core/workspace.ts:602

When something in this workspace changes, call a function. Note that there may be a few recent events already on the stack. Thus the new change listener might be called with events that occurred a few milliseconds before the change listener was added.

Parameters​

ParameterTypeDescription
func(e) => voidFunction to call.

Returns​

Obsolete return value, ignore.

(e) => void

Inherited from​

Workspace.addChangeListener


removeChangeListener()​

removeChangeListener(func): void;

Defined in: packages/blockly/core/workspace.ts:612

Stop listening for this workspace's changes.

Parameters​

ParameterTypeDescription
func(e) => voidFunction to stop calling.

Returns​

void

Inherited from​

Workspace.removeChangeListener


fireChangeListener()​

fireChangeListener(event): void;

Defined in: packages/blockly/core/workspace.ts:621

Fire a change event.

Parameters​

ParameterTypeDescription
eventAbstractEvent to fire.

Returns​

void

Inherited from​

Workspace.fireChangeListener


allInputsFilled()​

allInputsFilled(opt_shadowBlocksAreFilled?): boolean;

Defined in: packages/blockly/core/workspace.ts:684

Checks whether all value and statement inputs in the workspace are filled with blocks.

Parameters​

ParameterTypeDescription
opt_shadowBlocksAreFilled?booleanAn optional argument controlling whether shadow blocks are counted as filled. Defaults to true.

Returns​

boolean

True if all inputs are filled, false otherwise.

Inherited from​

Workspace.allInputsFilled


getPotentialVariableMap()​

getPotentialVariableMap():
| IVariableMap<IVariableModel<IVariableState>>
| null;

Defined in: packages/blockly/core/workspace.ts:701

Return the variable map that contains "potential" variables. These exist in the flyout but not in the workspace.

Returns​

| IVariableMap<IVariableModel<IVariableState>> | null

The potential variable map.

Inherited from​

Workspace.getPotentialVariableMap


getVariableMap()​

getVariableMap(): IVariableMap<IVariableModel<IVariableState>>;

Defined in: packages/blockly/core/workspace.ts:722

Return the map of all variables on the workspace.

Returns​

IVariableMap<IVariableModel<IVariableState>>

The variable map.

Inherited from​

Workspace.getVariableMap


getProcedureMap()​

getProcedureMap(): IProcedureMap;

Defined in: packages/blockly/core/workspace.ts:737

Returns the map of all procedures on the workpace.

Returns​

IProcedureMap

Inherited from​

Workspace.getProcedureMap


getById()​

static getById(id): Workspace | null;

Defined in: packages/blockly/core/workspace.ts:769

Find the workspace with the specified ID.

Parameters​

ParameterTypeDescription
idstringID of workspace to find.

Returns​

Workspace | null

The sought after workspace or null if not found.

Inherited from​

Workspace.getById


getAll()​

static getAll(): Workspace[];

Defined in: packages/blockly/core/workspace.ts:778

Find all workspaces.

Returns​

Workspace[]

Array of workspaces.

Inherited from​

Workspace.getAll


getVariableMapClass()​

protected getVariableMapClass(): (...p1) => IVariableMap<IVariableModel<IVariableState>>;

Defined in: packages/blockly/core/workspace.ts:782

Returns​

(...p1) => IVariableMap<IVariableModel<IVariableState>>

Inherited from​

Workspace.getVariableMapClass


isReadOnly()​

isReadOnly(): boolean;

Defined in: packages/blockly/core/workspace.ts:801

Returns whether or not this workspace is in readonly mode.

Returns​

boolean

True if the workspace is readonly, otherwise false.

Inherited from​

Workspace.isReadOnly


getMetricsManager()​

getMetricsManager(): IMetricsManager;

Defined in: packages/blockly/core/workspace_svg.ts:452

Gets the metrics manager for this workspace.

Returns​

IMetricsManager

The metrics manager.


getComponentManager()​

getComponentManager(): ComponentManager;

Defined in: packages/blockly/core/workspace_svg.ts:472

Gets the component manager for this workspace.

Returns​

ComponentManager

The component manager.


getRenderer()​

getRenderer(): Renderer;

Defined in: packages/blockly/core/workspace_svg.ts:481

Get the block renderer attached to this workspace.

Returns​

Renderer

The renderer attached to this workspace.


getTheme()​

getTheme(): Theme;

Defined in: packages/blockly/core/workspace_svg.ts:500

Get the workspace theme object.

Returns​

Theme

The workspace theme object.


setTheme()​

setTheme(theme): void;

Defined in: packages/blockly/core/workspace_svg.ts:510

Set the workspace theme object. If no theme is passed, default to the Classic theme.

Parameters​

ParameterTypeDescription
themeThemeThe workspace theme object.

Returns​

void


refreshTheme()​

refreshTheme(): void;

Defined in: packages/blockly/core/workspace_svg.ts:520

Refresh all blocks on the workspace after a theme update.

Returns​

void


getInverseScreenCTM()​

getInverseScreenCTM(): DOMMatrix | null;

Defined in: packages/blockly/core/workspace_svg.ts:573

Getter for the inverted screen CTM.

Returns​

DOMMatrix | null

The matrix to use in mouseToSvg


updateInverseScreenCTM()​

updateInverseScreenCTM(): void;

Defined in: packages/blockly/core/workspace_svg.ts:588

Mark the inverse screen CTM as dirty.

Returns​

void


isVisible()​

isVisible(): boolean;

Defined in: packages/blockly/core/workspace_svg.ts:598

Getter for isVisible

Returns​

boolean

Whether the workspace is visible. False if the workspace has been hidden by calling setVisible(false).


getSvgGroup()​

getSvgGroup(): Element;

Defined in: packages/blockly/core/workspace_svg.ts:699

Returns the SVG group for the workspace.

Returns​

Element

The SVG group for the workspace.


setResizeHandlerWrapper()​

setResizeHandlerWrapper(handler): void;

Defined in: packages/blockly/core/workspace_svg.ts:718

Save resize handler data so we can delete it later in dispose.

Parameters​

ParameterTypeDescription
handlerDataData that can be passed to eventHandling.unbind.

Returns​

void


setInitialAriaContext()​

setInitialAriaContext(): void;

Defined in: packages/blockly/core/workspace_svg.ts:725

Sets Aria labels, roles, etc. for the workspace depending on the type of workspace it is.

Returns​

void


createDom()​

createDom(opt_backgroundClass?, injectionDiv?): Element;

Defined in: packages/blockly/core/workspace_svg.ts:794

Create the workspace DOM elements.

Parameters​

ParameterTypeDescription
opt_backgroundClass?stringEither 'blocklyMainBackground' or 'blocklyMutatorBackground'.
injectionDiv?HTMLElement-

Returns​

Element

The workspace's SVG group.


dispose()​

dispose(): void;

Defined in: packages/blockly/core/workspace_svg.ts:927

Dispose of this workspace. Unlink from all DOM elements to prevent memory leaks.

Returns​

void

Overrides​

Workspace.dispose


copyOptionsForFlyout()​

copyOptionsForFlyout(): Options;

Defined in: packages/blockly/core/workspace_svg.ts:1048

Creates a new set of options from this workspace's options with just the values that are relevant to a flyout.

Returns​

Options

A subset of this workspace's options.


getFlyout()​

getFlyout(opt_own?): IFlyout | null;

Defined in: packages/blockly/core/workspace_svg.ts:1106

Getter for the flyout associated with this workspace. This flyout may be owned by either the toolbox or the workspace, depending on toolbox configuration. It will be null if there is no flyout.

Parameters​

ParameterTypeDescription
opt_own?booleanWhether to only return the workspace's own flyout.

Returns​

IFlyout | null

The flyout on this workspace.


getToolbox()​

getToolbox(): IToolbox | null;

Defined in: packages/blockly/core/workspace_svg.ts:1121

Getter for the toolbox associated with this workspace, if one exists.

Returns​

IToolbox | null

The toolbox on this workspace.


resize()​

resize(): void;

Defined in: packages/blockly/core/workspace_svg.ts:1158

Resize and reposition all of the workspace chrome (toolbox, trash, scrollbars etc.) This should be called when something changes that requires recalculating dimensions and positions of the trash, zoom, toolbox, etc. (e.g. window resize).

Returns​

void


getCanvas()​

getCanvas(): SVGGElement;

Defined in: packages/blockly/core/workspace_svg.ts:1234

Get the SVG element that forms the drawing surface.

Returns​

SVGGElement

SVG group element.


getBubbleCanvas()​

getBubbleCanvas(): SVGGElement;

Defined in: packages/blockly/core/workspace_svg.ts:1267

Get the SVG element that forms the bubble surface.

Returns​

SVGGElement

SVG group element.


getParentSvg()​

getParentSvg(): SVGSVGElement;

Defined in: packages/blockly/core/workspace_svg.ts:1278

Get the SVG element that contains this workspace. Note: We assume this is only called after the workspace has been injected into the DOM.

Returns​

SVGSVGElement

SVG element.


translate()​

translate(x, y): void;

Defined in: packages/blockly/core/workspace_svg.ts:1335

Translate this workspace to new coordinates.

Parameters​

ParameterTypeDescription
xnumberHorizontal translation, in pixel units relative to the top left of the Blockly div.
ynumberVertical translation, in pixel units relative to the top left of the Blockly div.

Returns​

void


getWidth()​

getWidth(): number;

Defined in: packages/blockly/core/workspace_svg.ts:1347

Returns the horizontal offset of the workspace. Intended for LTR/RTL compatibility in XML.

Returns​

number

Width.

Overrides​

Workspace.getWidth


setVisible()​

setVisible(isVisible): void;

Defined in: packages/blockly/core/workspace_svg.ts:1358

Toggles the visibility of the workspace. Currently only intended for main workspace.

Parameters​

ParameterTypeDescription
isVisiblebooleanTrue if workspace should be visible.

Returns​

void


render()​

render(): void;

Defined in: packages/blockly/core/workspace_svg.ts:1389

Render all blocks in workspace.

Returns​

void


highlightBlock()​

highlightBlock(id, opt_state?): void;

Defined in: packages/blockly/core/workspace_svg.ts:1413

Highlight or unhighlight a block in the workspace. Block highlighting is often used to visually mark blocks currently being executed.

Parameters​

ParameterTypeDescription
idstring | nullID of block to highlight/unhighlight, or null for no block (used to unhighlight all blocks).
opt_state?booleanIf undefined, highlight specified block and automatically unhighlight all others. If true or false, manually highlight/unhighlight the specified block.

Returns​

void


recordDragTargets()​

recordDragTargets(): void;

Defined in: packages/blockly/core/workspace_svg.ts:1465

Make a list of all the delete areas for this workspace.

Returns​

void


newBlock()​

newBlock(prototypeName, opt_id?): BlockSvg;

Defined in: packages/blockly/core/workspace_svg.ts:1493

Obtain a newly created block.

Parameters​

ParameterTypeDescription
prototypeNamestringName of the language object containing type-specific functions for this block.
opt_id?stringOptional ID. Use this ID if provided, otherwise create a new ID.

Returns​

BlockSvg

The created block.

Overrides​

Workspace.newBlock


newComment()​

newComment(id?): WorkspaceComment;

Defined in: packages/blockly/core/workspace_svg.ts:1507

Obtain a newly created comment.

Parameters​

ParameterTypeDescription
id?stringOptional ID. Use this ID if provided, otherwise create a new ID.

Returns​

WorkspaceComment

The created comment.

Overrides​

Workspace.newComment


getDragTarget()​

getDragTarget(point): IDragTarget | null;

Defined in: packages/blockly/core/workspace_svg.ts:1521

Returns the drag target at the given point.

Parameters​

ParameterTypeDescription
point| Coordinate | PointerEventA pointer event, or a point in client/viewport coordinates.

Returns​

IDragTarget | null

Null if not over a drag target, or the drag target at that point.


startDrag()​

startDrag(e, xy): void;

Defined in: packages/blockly/core/workspace_svg.ts:1552

Start tracking a drag of an object on this workspace.

Parameters​

ParameterTypeDescription
ePointerEventPointer down event.
xyCoordinateStarting location of object.

Returns​

void


moveDrag()​

moveDrag(e): Coordinate;

Defined in: packages/blockly/core/workspace_svg.ts:1562

Track a drag of an object on this workspace.

Parameters​

ParameterTypeDescription
ePointerEventPointer move event.

Returns​

Coordinate

New location of object.


isDragging()​

isDragging(): boolean;

Defined in: packages/blockly/core/workspace_svg.ts:1580

Returns true iff the user is currently engaged in a drag gesture, or if a keyboard-initated move is in progress.

Dragging gestures normally entail moving a block or other item on the workspace, or scrolling the flyout/workspace.

Keyboard-initated movements are implemnted using the dragging infrastructure and are intended to emulate (a subset of) drag gestures and so should typically be treated as if they were a gesture-based drag.

Returns​

boolean

True iff a drag gesture or keyboard move is in porgress.


isDraggable()​

isDraggable(): boolean;

Defined in: packages/blockly/core/workspace_svg.ts:1592

Is this workspace draggable?

Returns​

boolean

True if this workspace may be dragged.


isMovable()​

isMovable(): boolean;

Defined in: packages/blockly/core/workspace_svg.ts:1607

Is this workspace movable?

This means the user can reposition the X Y coordinates of the workspace through input. This can be through scrollbars, scroll wheel, dragging, or through zooming with the scroll wheel or pinch (since the zoom is centered on the mouse position). This does not include zooming with the zoom controls since the X Y coordinates are decided programmatically.

Returns​

boolean

True if the workspace is movable, false otherwise.


isMovableHorizontally()​

isMovableHorizontally(): boolean;

Defined in: packages/blockly/core/workspace_svg.ts:1622

Is this workspace movable horizontally?

Returns​

boolean

True if the workspace is movable horizontally, false otherwise.


isMovableVertically()​

isMovableVertically(): boolean;

Defined in: packages/blockly/core/workspace_svg.ts:1636

Is this workspace movable vertically?

Returns​

boolean

True if the workspace is movable vertically, false otherwise.


getBlocksBoundingBox()​

getBlocksBoundingBox(): Rect;

Defined in: packages/blockly/core/workspace_svg.ts:1710

Calculate the bounding box for the blocks on the workspace. Coordinate system: workspace coordinates.

Returns​

Rect

Contains the position and size of the bounding box containing the blocks on the workspace.


cleanUp()​

cleanUp(): void;

Defined in: packages/blockly/core/workspace_svg.ts:1747

Clean up the workspace by ordering all the blocks in a column such that none overlap.

Returns​

void


updateToolbox()​

updateToolbox(toolboxDef): void;

Defined in: packages/blockly/core/workspace_svg.ts:1848

Modify the block tree on the existing toolbox.

Parameters​

ParameterTypeDescription
toolboxDef| ToolboxDefinition | nullDOM tree of toolbox contents, string of toolbox contents, or JSON representing toolbox definition.

Returns​

void


markFocused()​

markFocused(): void;

Defined in: packages/blockly/core/workspace_svg.ts:1877

Mark this workspace as the currently focused main workspace.

Returns​

void


zoom()​

zoom(
x,
y,
amount
): void;

Defined in: packages/blockly/core/workspace_svg.ts:1902

Zooms the workspace in or out relative to/centered on the given (x, y) coordinate.

Parameters​

ParameterTypeDescription
xnumberX coordinate of center, in pixel units relative to the top-left corner of the parentSVG.
ynumberY coordinate of center, in pixel units relative to the top-left corner of the parentSVG.
amountnumberAmount of zooming. The formula for the new scale is newScale = currentScale * (scaleSpeed^amount). scaleSpeed is set in the workspace options. Negative amount values zoom out, and positive amount values zoom in.

Returns​

void


zoomCenter()​

zoomCenter(type): void;

Defined in: packages/blockly/core/workspace_svg.ts:1949

Zooming the blocks centered in the center of view with zooming in or out.

Parameters​

ParameterTypeDescription
typenumberType of zooming (-1 zooming out and 1 zooming in).

Returns​

void


zoomToFit()​

zoomToFit(): void;

Defined in: packages/blockly/core/workspace_svg.ts:1969

Zoom the blocks to fit in the workspace if possible.

Returns​

void


scrollCenter()​

scrollCenter(): void;

Defined in: packages/blockly/core/workspace_svg.ts:2039

Center the workspace.

Returns​

void


centerOnBlock()​

centerOnBlock(id, blockOnly?): void;

Defined in: packages/blockly/core/workspace_svg.ts:2066

Scroll the workspace to center on the given block. If the block has other blocks stacked below it, the workspace will be centered on the stack, unless blockOnly is true.

Parameters​

ParameterTypeDescription
idstring | nullID of block center on.
blockOnly?booleanTrue to center only on the block itself, not its stack.

Returns​

void


setScale()​

setScale(newScale): void;

Defined in: packages/blockly/core/workspace_svg.ts:2125

Set the workspace's zoom factor.

Parameters​

ParameterTypeDescription
newScalenumberZoom factor. Units: (pixels / workspaceUnit).

Returns​

void


getScale()​

getScale(): number;

Defined in: packages/blockly/core/workspace_svg.ts:2178

Get the workspace's zoom factor.

Returns​

number

The workspace zoom factor. Units: (pixels / workspaceUnit).


getAbsoluteScale()​

getAbsoluteScale(): number;

Defined in: packages/blockly/core/workspace_svg.ts:2197

Returns the absolute scale of the workspace.

Workspace scaling is multiplicative; if a workspace B (e.g. a mutator editor) with scale Y is nested within a root workspace A with scale X, workspace B's effective scale is X * Y, because, as a child of A, it is already transformed by A's scaling factor, and then further transforms itself by its own scaling factor. Normally this Just Works, but for global elements (e.g. field editors) that are visually associated with a particular workspace but live at the top level of the DOM rather than being a child of their associated workspace, the absolute/effective scale may be needed to render appropriately.

Returns​

number

The absolute/effective scale of the given workspace.


scroll()​

scroll(
x,
y,
shouldHidePopups?
): void;

Defined in: packages/blockly/core/workspace_svg.ts:2246

Scroll the workspace to a specified offset (in pixels), keeping in the workspace bounds. See comment on workspaceSvg.scrollX for more detail on the meaning of these values.

Parameters​

ParameterTypeDefault valueDescription
xnumberundefinedTarget X to scroll to.
ynumberundefinedTarget Y to scroll to.
shouldHidePopupsbooleantrueWhether to hide popups. Defaults to true.

Returns​

void


getBlockById()​

getBlockById(id): BlockSvg | null;

Defined in: packages/blockly/core/workspace_svg.ts:2298

Find the block on this workspace with the specified ID.

Parameters​

ParameterTypeDescription
idstringID of block to find.

Returns​

BlockSvg | null

The sought after block, or null if not found.

Overrides​

Workspace.getBlockById


getAllBlocks()​

getAllBlocks(ordered?): BlockSvg[];

Defined in: packages/blockly/core/workspace_svg.ts:2309

Find all blocks in workspace. Blocks are optionally sorted by position; top to bottom (with slight LTR or RTL bias).

Parameters​

ParameterTypeDefault valueDescription
orderedbooleanfalseSort the list if true.

Returns​

BlockSvg[]

Array of blocks.

Overrides​

Workspace.getAllBlocks


getTopBlocks()​

getTopBlocks(ordered?): BlockSvg[];

Defined in: packages/blockly/core/workspace_svg.ts:2320

Finds the top-level blocks and returns them. Blocks are optionally sorted by position; top to bottom (with slight LTR or RTL bias).

Parameters​

ParameterTypeDefault valueDescription
orderedbooleanfalseSort the list if true.

Returns​

BlockSvg[]

The top-level block objects.

Overrides​

Workspace.getTopBlocks


addTopBlock()​

addTopBlock(block): void;

Defined in: packages/blockly/core/workspace_svg.ts:2329

Adds a block to the list of top blocks.

Parameters​

ParameterTypeDescription
blockBlockBlock to add.

Returns​

void

Overrides​

Workspace.addTopBlock


removeTopBlock()​

removeTopBlock(block): void;

Defined in: packages/blockly/core/workspace_svg.ts:2339

Removes a block from the list of top blocks.

Parameters​

ParameterTypeDescription
blockBlockBlock to remove.

Returns​

void

Overrides​

Workspace.removeTopBlock


addTopComment()​

addTopComment(comment): void;

Defined in: packages/blockly/core/workspace_svg.ts:2349

Adds a comment to the list of top comments.

Parameters​

ParameterTypeDescription
commentRenderedWorkspaceCommentcomment to add.

Returns​

void

Overrides​

Workspace.addTopComment

removeTopComment()​

removeTopComment(comment): void;

Defined in: packages/blockly/core/workspace_svg.ts:2359

Removes a comment from the list of top comments.

Parameters​

ParameterTypeDescription
commentRenderedWorkspaceCommentcomment to remove.

Returns​

void

Overrides​

Workspace.removeTopComment

getTopComments()​

getTopComments(ordered?): RenderedWorkspaceComment[];

Defined in: packages/blockly/core/workspace_svg.ts:2370

Returns a list of comments on this workspace.

Parameters​

ParameterTypeDefault valueDescription
orderedbooleanfalseIf true, sorts the comments based on their position.

Returns​

RenderedWorkspaceComment[]

A list of workspace comments.

Overrides​

Workspace.getTopComments

getCommentById()​

getCommentById(id):
| RenderedWorkspaceComment
| null;

Defined in: packages/blockly/core/workspace_svg.ts:2380

Returns the workspace comment with the given ID, if any.

Parameters​

ParameterTypeDescription
idstringThe ID of the comment to retrieve.

Returns​

| RenderedWorkspaceComment | null

The workspace comment with the given ID, or null.

Overrides​

Workspace.getCommentById


getRootWorkspace()​

getRootWorkspace(): WorkspaceSvg | null;

Defined in: packages/blockly/core/workspace_svg.ts:2384

Returns the root workspace of this workspace if the workspace has parent(s).

E.g. workspaces in flyouts and mini workspace bubbles have parent workspaces.

Returns​

WorkspaceSvg | null

Overrides​

Workspace.getRootWorkspace


addTopBoundedElement()​

addTopBoundedElement(element): void;

Defined in: packages/blockly/core/workspace_svg.ts:2393

Adds a bounded element to the list of top bounded elements.

Parameters​

ParameterTypeDescription
elementIBoundedElementBounded element to add.

Returns​

void


removeTopBoundedElement()​

removeTopBoundedElement(element): void;

Defined in: packages/blockly/core/workspace_svg.ts:2402

Removes a bounded element from the list of top bounded elements.

Parameters​

ParameterTypeDescription
elementIBoundedElementBounded element to remove.

Returns​

void


getTopBoundedElements()​

getTopBoundedElements(ordered?): IBoundedElement[];

Defined in: packages/blockly/core/workspace_svg.ts:2411

Finds the top-level bounded elements and returns them.

Parameters​

ParameterTypeDefault value
orderedbooleanfalse

Returns​

IBoundedElement[]

The top-level bounded elements.


setResizesEnabled()​

setResizesEnabled(enabled): void;

Defined in: packages/blockly/core/workspace_svg.ts:2430

Update whether this workspace has resizes enabled. If enabled, workspace will resize when appropriate. If disabled, workspace will not resize until re-enabled. Use to avoid resizing during a batch operation, for performance.

Parameters​

ParameterTypeDescription
enabledbooleanWhether resizes should be enabled.

Returns​

void


clear()​

clear(): void;

Defined in: packages/blockly/core/workspace_svg.ts:2443

Dispose of all blocks in workspace, with an optimization to prevent resizes.

Returns​

void

Overrides​

Workspace.clear


registerButtonCallback()​

registerButtonCallback(key, func): void;

Defined in: packages/blockly/core/workspace_svg.ts:2461

Register a callback function associated with a given key, for clicks on buttons and labels in the flyout. For instance, a button specified by the XML should be matched by a call to registerButtonCallback("CREATE_VARIABLE", yourCallbackFunction).

Parameters​

ParameterTypeDescription
keystringThe name to use to look up this function.
func(p1) => voidThe function to call when the given button is clicked.

Returns​

void


getButtonCallback()​

getButtonCallback(key): ((p1) => void) | null;

Defined in: packages/blockly/core/workspace_svg.ts:2476

Get the callback function associated with a given key, for clicks on buttons and labels in the flyout.

Parameters​

ParameterTypeDescription
keystringThe name to use to look up the function.

Returns​

((p1) => void) | null

The function corresponding to the given key for this workspace; null if no callback is registered.


removeButtonCallback()​

removeButtonCallback(key): void;

Defined in: packages/blockly/core/workspace_svg.ts:2485

Remove a callback for a click on a button in the flyout.

Parameters​

ParameterTypeDescription
keystringThe name associated with the callback function.

Returns​

void


registerToolboxCategoryCallback()​

registerToolboxCategoryCallback(key, func): void;

Defined in: packages/blockly/core/workspace_svg.ts:2497

Register a callback function associated with a given key, for populating custom toolbox categories in this workspace. See the variable and procedure categories as an example.

Parameters​

ParameterTypeDescription
keystringThe name to use to look up this function.
func(p1) => FlyoutDefinitionThe function to call when the given toolbox category is opened.

Returns​

void


getToolboxCategoryCallback()​

getToolboxCategoryCallback(key):
| ((p1) => FlyoutDefinition)
| null;

Defined in: packages/blockly/core/workspace_svg.ts:2515

Get the callback function associated with a given key, for populating custom toolbox categories in this workspace.

Parameters​

ParameterTypeDescription
keystringThe name to use to look up the function.

Returns​

| ((p1) => FlyoutDefinition) | null

The function corresponding to the given key for this workspace, or null if no function is registered.


removeToolboxCategoryCallback()​

removeToolboxCategoryCallback(key): void;

Defined in: packages/blockly/core/workspace_svg.ts:2526

Remove a callback for a click on a custom category's name in the toolbox.

Parameters​

ParameterTypeDescription
keystringThe name associated with the callback function.

Returns​

void


getAudioManager()​

getAudioManager(): WorkspaceAudio;

Defined in: packages/blockly/core/workspace_svg.ts:2599

Get the audio manager for this workspace.

Returns​

WorkspaceAudio

The audio manager for this workspace.


getGrid()​

getGrid(): Grid | null;

Defined in: packages/blockly/core/workspace_svg.ts:2608

Get the grid object for this workspace, or null if there is none.

Returns​

Grid | null

The grid object for this workspace.


hideChaff()​

hideChaff(onlyClosePopups?): void;

Defined in: packages/blockly/core/workspace_svg.ts:2618

Close tooltips, context menus, dropdown selections, etc.

Parameters​

ParameterTypeDefault valueDescription
onlyClosePopupsbooleanfalseWhether only popups should be closed. Defaults to false.

Returns​

void


hideComponents()​

hideComponents(onlyClosePopups?): void;

Defined in: packages/blockly/core/workspace_svg.ts:2633

Hide any autohideable components (like flyout, trashcan, and any user-registered components).

Parameters​

ParameterTypeDefault valueDescription
onlyClosePopupsbooleanfalseWhether only popups should be closed. Defaults to false.

Returns​

void


addClass()​

addClass(className): void;

Defined in: packages/blockly/core/workspace_svg.ts:2680

Adds a CSS class to the workspace.

Parameters​

ParameterTypeDescription
classNamestringName of class to add.

Returns​

void


removeClass()​

removeClass(className): void;

Defined in: packages/blockly/core/workspace_svg.ts:2691

Removes a CSS class from the workspace.

Parameters​

ParameterTypeDescription
classNamestringName of class to remove.

Returns​

void


setIsReadOnly()​

setIsReadOnly(readOnly): void;

Defined in: packages/blockly/core/workspace_svg.ts:2697

Sets whether or not this workspace is in readonly mode.

Parameters​

ParameterTypeDescription
readOnlybooleanTrue to make the workspace readonly, otherwise false.

Returns​

void

Overrides​

Workspace.setIsReadOnly


getFocusableElement()​

getFocusableElement(): HTMLElement | SVGElement;

Defined in: packages/blockly/core/workspace_svg.ts:2785

See IFocusableNode.getFocusableElement.

Returns​

HTMLElement | SVGElement

Implementation of​

IFocusableNode.getFocusableElement


getFocusableTree()​

getFocusableTree(): IFocusableTree;

Defined in: packages/blockly/core/workspace_svg.ts:2790

See IFocusableNode.getFocusableTree.

Returns​

IFocusableTree

Implementation of​

IFocusableNode.getFocusableTree


onNodeFocus()​

onNodeFocus(): void;

Defined in: packages/blockly/core/workspace_svg.ts:2795

See IFocusableNode.onNodeFocus.

Returns​

void

Implementation of​

IFocusableNode.onNodeFocus


onNodeBlur()​

onNodeBlur(): void;

Defined in: packages/blockly/core/workspace_svg.ts:2831

See IFocusableNode.onNodeBlur.

Returns​

void

Implementation of​

IFocusableNode.onNodeBlur


canBeFocused()​

canBeFocused(): boolean;

Defined in: packages/blockly/core/workspace_svg.ts:2834

See IFocusableNode.canBeFocused.

Returns​

boolean

Implementation of​

IFocusableNode.canBeFocused


getRootFocusableNode()​

getRootFocusableNode(): IFocusableNode;

Defined in: packages/blockly/core/workspace_svg.ts:2839

See IFocusableTree.getRootFocusableNode.

Returns​

IFocusableNode

Implementation of​

IFocusableTree.getRootFocusableNode


getRestoredFocusableNode()​

getRestoredFocusableNode(previousNode): IFocusableNode | null;

Defined in: packages/blockly/core/workspace_svg.ts:2844

See IFocusableTree.getRestoredFocusableNode.

Parameters​

ParameterType
previousNodeIFocusableNode | null

Returns​

IFocusableNode | null

Implementation of​

IFocusableTree.getRestoredFocusableNode


getWorkspaceFocusTarget()​

getWorkspaceFocusTarget(): WorkspaceFocusTarget | null;

Defined in: packages/blockly/core/workspace_svg.ts:2881

Returns the focusable node representing this workspace as a whole, or null for workspaces without one (flyouts and mutators).

Focus lands here when the workspace itself is focused (e.g. via the focus workspace shortcut) rather than on any of its contents.

Returns​

WorkspaceFocusTarget | null

This workspace's focus target node, if any.


getNestedTrees()​

getNestedTrees(): IFocusableTree[];

Defined in: packages/blockly/core/workspace_svg.ts:2886

See IFocusableTree.getNestedTrees.

Returns​

IFocusableTree[]

Implementation of​

IFocusableTree.getNestedTrees


lookUpFocusableNode()​

lookUpFocusableNode(id): IFocusableNode | null;

Defined in: packages/blockly/core/workspace_svg.ts:2922

See IFocusableTree.lookUpFocusableNode.

Parameters​

ParameterType
idstring

Returns​

IFocusableNode | null

Implementation of​

IFocusableTree.lookUpFocusableNode


onTreeFocus()​

onTreeFocus(_node, _previousTree): void;

Defined in: packages/blockly/core/workspace_svg.ts:3046

See IFocusableTree.onTreeFocus.

Parameters​

ParameterType
_nodeIFocusableNode
_previousTreeIFocusableTree | null

Returns​

void

Implementation of​

IFocusableTree.onTreeFocus


onTreeBlur()​

onTreeBlur(nextTree): void;

Defined in: packages/blockly/core/workspace_svg.ts:3056

See IFocusableTree.onTreeBlur.

Parameters​

ParameterType
nextTreeIFocusableTree | null

Returns​

void

Implementation of​

IFocusableTree.onTreeBlur


performAction()​

performAction(): void;

Defined in: packages/blockly/core/workspace_svg.ts:3089

Handles the user acting on this workspace via keyboard navigation by prompting them to use the arrow keys (instead of Enter) to navigate.

Returns​

void

Implementation of​

IFocusableNode.performAction


getNavigator()​

getNavigator(): Navigator;

Defined in: packages/blockly/core/workspace_svg.ts:3099

Returns an object responsible for coordinating movement of focus between items on this workspace in response to keyboard navigation commands.

Returns​

Navigator

This workspace's Navigator instance.

Implementation of​

IFocusableTree.getNavigator


setNavigator()​

setNavigator(newNavigator): void;

Defined in: packages/blockly/core/workspace_svg.ts:3109

Sets the Navigator instance used by this workspace.

Parameters​

ParameterTypeDescription
newNavigatorNavigatorA Navigator object to coordinate movement between elements on the workspace.

Returns​

void