Stay organized with collections
Save and categorize content based on your preferences.
blockly > DragTarget
DragTarget class
Abstract class for a component with custom behaviour when a block or bubble is dragged over or dropped on top of it.
Signature:
export declare class DragTarget implements IDragTarget
Implements: IDragTarget
Constructors
Constructor |
Modifiers |
Description |
(constructor)() |
|
Constructor for DragTarget. It exists to add the id property and should not be called directly, only by a subclass. |
Properties
Property |
Modifiers |
Type |
Description |
id |
|
string |
The unique id for this component that is used to register with the ComponentManager. |
Methods
Method |
Modifiers |
Description |
getClientRect() |
|
Returns the bounding rectangle of the drag target area in pixel units relative to the Blockly injection div. |
onDragEnter(_dragElement) |
|
Handles when a cursor with a block or bubble enters this drag target. |
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. |
shouldPreventMove(_dragElement) |
|
Returns whether the provided block or bubble should not be moved after being dropped on this component. If true, the element will return to where it was when the drag started. |
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."],[[["The `DragTarget` class in Blockly defines how components react when blocks or bubbles are dragged over or dropped on them."],["It's an abstract class with a unique ID, primarily used as a base for custom drag-and-drop interactions."],["Key methods include `onDragEnter`, `onDragOver`, `onDragExit`, `onDrop` for handling drag events and `shouldPreventMove` to control drop behavior."],["Developers extend `DragTarget` to create custom drop zones in Blockly workspaces with specific functionalities."]]],[]]