Blockly. Bubble
Class for UI bubble.
Constructor
Bubble
new Bubble(workspace, content, shape, anchorXY, bubbleWidth, bubbleHeight)
Parameter |
|
---|---|
workspace |
The workspace on which to draw the bubble. Value must not be null. |
content |
SVG content for the bubble. Value must not be null. |
shape |
SVG element to avoid eclipsing. Value must not be null. |
anchorXY |
Absolute position of bubble's anchor point. Value must not be null. |
bubbleWidth |
Width of bubble, or null if not resizable. Value may be null. |
bubbleHeight |
Height of bubble, or null if not resizable. Value may be null. |
- Implements
- Blockly.IBubble
Properties
ANCHOR_RADIUS
Distance between arrow point and anchor point.
ARROW_ANGLE
The number of degrees that the arrow bends counter-clockwise.
ARROW_BEND
The sharpness of the arrow's bend. Higher numbers result in smoother arrows.
ARROW_THICKNESS
Determines the thickness of the base of the arrow in relation to the size of the bubble. Higher numbers result in thinner arrows.
BORDER_WIDTH
Width of the border around the bubble.
bubbleGroup_
non-null SVGElement
disposed
boolean
Describes whether this bubble has been disposed of (nodes and event listeners removed from the page) or not.
Methods
createNonEditableBubble
createNonEditableBubble(paragraphElement, block, iconXY) returns Blockly.Bubble
Creates a bubble that can not be edited.
Parameter |
|
---|---|
paragraphElement |
SVGTextElement The text element for the non editable bubble. Value must not be null. |
block |
The block that the bubble is attached to. Value must not be null. |
iconXY |
The coordinate of the icon. Value must not be null. |
- Returns
-
non-null Blockly.Bubble
The non editable bubble.
textToDom
textToDom(text) returns SVGTextElement
Create the text for a non editable bubble.
Parameter |
|
---|---|
text |
string The text to display. |
- Returns
-
non-null SVGTextElement
The top-level node of the text.
dispose
dispose()
Dispose of this bubble.
- Implements
- Blockly.IBubble#dispose
getBubbleSize
getBubbleSize() returns Blockly.utils.Size
Get the dimensions of this bubble.
- Returns
-
non-null Blockly.utils.Size
The height and width of the bubble.
getRelativeToSurfaceXY
getRelativeToSurfaceXY() returns Blockly.utils.Coordinate
Return the coordinates of the top-left corner of this bubble's body relative to the drawing surface's origin (0,0), in workspace units.
- Implements
- Blockly.IBubble#getRelativeToSurfaceXY
- Returns
-
non-null Blockly.utils.Coordinate
Object with .x and .y properties.
getSvgRoot
getSvgRoot() returns SVGElement
Return the root node of the bubble's SVG group.
- Implements
- Blockly.IBubble#getSvgRoot
- Returns
-
non-null SVGElement
The root SVG node of the bubble's group.
isDeletable
isDeletable() returns boolean
Get whether this bubble is deletable or not.
- Implements
- Blockly.IBubble#isDeletable
- Returns
-
boolean
True if deletable.
moveDuringDrag
moveDuringDrag(dragSurface, newLoc)
Move this bubble during a drag, taking into account whether or not there is a drag surface.
Parameter |
|
---|---|
dragSurface |
The surface that carries rendered items during a drag, or null if no drag surface is in use. |
newLoc |
The location to translate to, in workspace coordinates. Value must not be null. |
- Implements
- Blockly.IBubble#moveDuringDrag
moveTo
moveTo(x, y)
Move the bubble group to the specified location in workspace coordinates.
Parameter |
|
---|---|
x |
number The x position to move to. |
y |
number The y position to move to. |
- Implements
- Blockly.IBubble#moveTo
promote
promote() returns boolean
Move this bubble to the top of the stack.
- Returns
-
boolean
Whether or not the bubble has been moved.
registerMoveEvent
registerMoveEvent(callback)
Register a function as a callback event for when the bubble is moved.
Parameter |
|
---|---|
callback |
function() The function to call on move. Value must not be null. |
registerResizeEvent
registerResizeEvent(callback)
Register a function as a callback event for when the bubble is resized.
Parameter |
|
---|---|
callback |
function() The function to call on resize. Value must not be null. |
setAnchorLocation
setAnchorLocation(xy)
Notification that the anchor has moved. Update the arrow and bubble accordingly.
Parameter |
|
---|---|
xy |
Absolute location. Value must not be null. |
setAutoLayout
setAutoLayout(enable)
Set whether auto-layout of this bubble is enabled. The first time a bubble is shown it positions itself to not cover any blocks. Once a user has dragged it to reposition, it renders where the user put it.
Parameter |
|
---|---|
enable |
boolean True if auto-layout should be enabled, false otherwise. |
- Implements
- Blockly.IBubble#setAutoLayout
setBubbleSize
setBubbleSize(width, height)
Size this bubble.
Parameter |
|
---|---|
width |
number Width of the bubble. |
height |
number Height of the bubble. |
setColour
setColour(hexColour)
Change the colour of a bubble.
Parameter |
|
---|---|
hexColour |
string Hex code of colour. |
setDeleteStyle
setDeleteStyle(_enable)
Update the style of this bubble when it is dragged over a delete area.
Parameter |
|
---|---|
_enable |
boolean True if the bubble is about to be deleted, false otherwise. |
- Implements
- Blockly.IBubble#setDeleteStyle
setDragging
setDragging(adding)
Triggers a move callback if one exists at the end of a drag.
Parameter |
|
---|---|
adding |
boolean True if adding, false if removing. |
- Implements
- Blockly.IBubble#setDragging
setSvgId
setSvgId(id)
Expose the block's ID on the bubble's top-level SVG group.
Parameter |
|
---|---|
id |
string ID of block. |
showContextMenu
showContextMenu(_e)
Show the context menu for this bubble.
Parameter |
|
---|---|
_e |
Event Mouse event. Value must not be null. |
- Implements
- Blockly.IBubble#showContextMenu