Stay organized with collections
Save and categorize content based on your preferences.
blockly > Trashcan
Trashcan class
Class for a trash can.
Signature:
export declare class Trashcan extends DeleteArea implements IAutoHideable, IPositionable
Extends: DeleteArea
Implements: IAutoHideable, IPositionable
Constructors
Properties
Property |
Modifiers |
Type |
Description |
id |
|
string |
The unique id for this component that is used to register with the ComponentManager. |
isLidOpen |
|
boolean |
Current open/close state of the lid. |
Methods
Method |
Modifiers |
Description |
autoHide(onlyClosePopups) |
|
Hides the component. Called in WorkspaceSvg.hideChaff. |
click() |
|
Inspect the contents of the trash. |
closeFlyout() |
|
Closes the trashcan flyout. |
closeLid() |
|
Flip the lid shut. Called externally after a drag. |
contentsIsOpen() |
|
Returns true if the trashcan contents-flyout is currently open. |
createDom() |
|
Create the trash can elements. |
dispose() |
|
Dispose of this trash can. Unlink from all DOM elements to prevent memory leaks. |
emptyContents() |
|
Empties the trashcan's contents. If the contents-flyout is currently open it will be closed. |
getBoundingRectangle() |
|
Returns the bounding rectangle of the UI element in pixel units relative to the Blockly injection div. |
getClientRect() |
|
Returns the bounding rectangle of the drag target area in pixel units relative to viewport. |
init() |
|
Initializes the trash can. |
onDragExit(_dragElement) |
|
Handles when a cursor with a block or bubble exits this drag target. |
onDragOver(_dragElement) |
|
Handles when a cursor with a block or bubble is dragged over this drag target. |
onDrop(_dragElement) |
|
Handles when a block or bubble is dropped on this component. Should not handle delete here. |
openFlyout() |
|
Opens the trashcan flyout. |
position(metrics, savedPositions) |
|
Positions the trashcan. It is positioned in the opposite corner to the corner the categories/toolbox starts at. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eTrashcan\u003c/code\u003e class manages the visual and interactive aspects of the Blockly trashcan, handling deletion of blocks and bubbles.\u003c/p\u003e\n"],["\u003cp\u003eIt extends the \u003ccode\u003eDeleteArea\u003c/code\u003e class and implements the \u003ccode\u003eIAutoHideable\u003c/code\u003e and \u003ccode\u003eIPositionable\u003c/code\u003e interfaces for managing visibility and positioning.\u003c/p\u003e\n"],["\u003cp\u003eKey functionalities include opening/closing the trashcan lid, displaying and emptying its contents via a flyout, and responding to drag-and-drop events.\u003c/p\u003e\n"],["\u003cp\u003eThe trashcan's position is dynamically determined based on the workspace layout, typically opposite the toolbox or categories.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can interact with the \u003ccode\u003eTrashcan\u003c/code\u003e through methods like \u003ccode\u003edispose()\u003c/code\u003e, \u003ccode\u003eemptyContents()\u003c/code\u003e, \u003ccode\u003eopenFlyout()\u003c/code\u003e, and \u003ccode\u003eposition()\u003c/code\u003e.\u003c/p\u003e\n"]]],["The `Trashcan` class, extending `DeleteArea`, manages a trash can component. It implements `IAutoHideable` and `IPositionable`. Key actions include constructing, initializing, and disposing of the trash can. The lid can be opened or closed, and the contents can be inspected, emptied, or displayed in a flyout. The trashcan also handles drag-and-drop interactions, such as drag exit, drag over, and drop events. Its position within the UI can be calculated.\n"],null,["[blockly](./blockly.md) \\\u003e [Trashcan](./blockly.trashcan_class.md)\n\nTrashcan class\n--------------\n\nClass for a trash can.\n\n**Signature:** \n\n export declare class Trashcan extends DeleteArea implements IAutoHideable, IPositionable \n\n**Extends:** [DeleteArea](./blockly.deletearea_class.md)\n\n**Implements:** [IAutoHideable](./blockly.iautohideable_interface.md), [IPositionable](./blockly.ipositionable_interface.md)\n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|-------------------------------------------------------------------------------------|-----------|---------------------------------------------------|\n| [(constructor)(workspace)](./blockly.trashcan_class._constructor__1_constructor.md) | | Constructs a new instance of the `Trashcan` class |\n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|-------------------------------------------------------------|-----------|---------|--------------------------------------------------------------------------------------|\n| [id](./blockly.trashcan_class.id_property.md) | | string | The unique id for this component that is used to register with the ComponentManager. |\n| [isLidOpen](./blockly.trashcan_class.islidopen_property.md) | | boolean | Current open/close state of the lid. |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|-------------------------------------------------------------------------------------|-----------|-----------------------------------------------------------------------------------------------------------------|\n| [autoHide(onlyClosePopups)](./blockly.trashcan_class.autohide_1_method.md) | | Hides the component. Called in WorkspaceSvg.hideChaff. |\n| [click()](./blockly.trashcan_class.click_1_method.md) | | Inspect the contents of the trash. |\n| [closeFlyout()](./blockly.trashcan_class.closeflyout_1_method.md) | | Closes the trashcan flyout. |\n| [closeLid()](./blockly.trashcan_class.closelid_1_method.md) | | Flip the lid shut. Called externally after a drag. |\n| [contentsIsOpen()](./blockly.trashcan_class.contentsisopen_1_method.md) | | Returns true if the trashcan contents-flyout is currently open. |\n| [createDom()](./blockly.trashcan_class.createdom_1_method.md) | | Create the trash can elements. |\n| [dispose()](./blockly.trashcan_class.dispose_1_method.md) | | Dispose of this trash can. Unlink from all DOM elements to prevent memory leaks. |\n| [emptyContents()](./blockly.trashcan_class.emptycontents_1_method.md) | | Empties the trashcan's contents. If the contents-flyout is currently open it will be closed. |\n| [getBoundingRectangle()](./blockly.trashcan_class.getboundingrectangle_1_method.md) | | Returns the bounding rectangle of the UI element in pixel units relative to the Blockly injection div. |\n| [getClientRect()](./blockly.trashcan_class.getclientrect_1_method.md) | | Returns the bounding rectangle of the drag target area in pixel units relative to viewport. |\n| [init()](./blockly.trashcan_class.init_1_method.md) | | Initializes the trash can. |\n| [onDragExit(_dragElement)](./blockly.trashcan_class.ondragexit_1_method.md) | | Handles when a cursor with a block or bubble exits this drag target. |\n| [onDragOver(_dragElement)](./blockly.trashcan_class.ondragover_1_method.md) | | Handles when a cursor with a block or bubble is dragged over this drag target. |\n| [onDrop(_dragElement)](./blockly.trashcan_class.ondrop_1_method.md) | | Handles when a block or bubble is dropped on this component. Should not handle delete here. |\n| [openFlyout()](./blockly.trashcan_class.openflyout_1_method.md) | | Opens the trashcan flyout. |\n| [position(metrics, savedPositions)](./blockly.trashcan_class.position_1_method.md) | | Positions the trashcan. It is positioned in the opposite corner to the corner the categories/toolbox starts at. |"]]