Register for the online Blockly Developer Summit April 28-29, 2021!

Class: Trashcan

Constructor

Trashcan

new Trashcan(workspace)

Class for a trash can.

Parameter

workspace

Blockly.WorkspaceSvg

The workspace to sit in.

Value must not be null.

Implements
Blockly.IDeleteArea
Blockly.IPositionable

Properties

flyout

package

Blockly.IFlyout

The trashcan flyout.

isLidOpen

boolean

Current open/close state of the lid.

Methods

click

click()

Inspect the contents of the trash.

closeFlyout

closeFlyout()

Closes the trashcan flyout.

closeLid

closeLid()

Flip the lid shut. Called externally after a drag.

contentsIsOpen

contentsIsOpen() returns boolean

Returns true if the trashcan contents-flyout is currently open.

Returns

boolean True if the trashcan contents-flyout is currently open.

createDom

createDom() returns SVGElement

Create the trash can elements.

Returns

non-null SVGElement The trash can's SVG group.

dispose

dispose()

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

emptyContents

emptyContents()

Empties the trashcan's contents. If the contents-flyout is currently open it will be closed.

getBoundingRectangle

getBoundingRectangle() returns Blockly.utils.Rect

Returns the bounding rectangle of the UI element in pixel units relative to the Blockly injection div.

Implements
Blockly.IPositionable#getBoundingRectangle
Returns

non-null Blockly.utils.Rect The plugin’s bounding box.

getClientRect

getClientRect() returns Blockly.utils.Rect

Return the deletion rectangle for this trash can.

Implements
Blockly.IDeleteArea#getClientRect
Returns

Blockly.utils.Rect Rectangle in which to delete.

init

init(verticalSpacing) returns number

Initialize the trash can.

Parameter

verticalSpacing

number

Vertical distance from workspace edge to the same edge of the trashcan.

Returns

number Vertical distance from workspace edge to the opposite edge of the trashcan.

openFlyout

openFlyout()

Opens the trashcan flyout.

position

position(metrics, savedPositions)

Positions the trashcan. It is positioned in the opposite corner to the corner the categories/toolbox starts at.

Parameter

metrics

Blockly.MetricsManager.UiMetrics

The workspace metrics.

Value must not be null.

savedPositions

Array of non-null Blockly.utils.Rect

List of rectangles that are already on the workspace.

Value must not be null.

Implements
Blockly.IPositionable#position

setLidOpen

package

setLidOpen(state)

Flip the lid open or shut.

Parameter

state

boolean

True if open.