Class: Bubble

Constructor

Bubble

new Bubble(workspace, content, shape, anchorXY, bubbleWidth, bubbleHeight)

Class for UI bubble.

Parameter

workspace

Blockly.WorkspaceSvg

The workspace on which to draw the bubble.

Value must not be null.

content

Element

SVG content for the bubble.

Value must not be null.

shape

Element

SVG element to avoid eclipsing.

anchorXY

Blockly.utils.Coordinate

Absolute position of bubble's anchor point.

Value must not be null.

bubbleWidth

number

Width of bubble, or null if not resizable.

Value may be null.

bubbleHeight

number

Height of bubble, or null if not resizable.

Value may be null.

Properties

ANCHOR_RADIUS

static

Distance between arrow point and anchor point.

ARROW_ANGLE

static

The number of degrees that the arrow bends counter-clockwise.

ARROW_BEND

static

The sharpness of the arrow's bend. Higher numbers result in smoother arrows.

ARROW_THICKNESS

static

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

static

Width of the border around the bubble.

disposed

package

boolean

Describes whether this bubble has been disposed of (nodes and event listeners removed from the page) or not.

Methods

dispose

dispose()

Dispose of this bubble.

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.

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.

Returns

SVGElement The root SVG node of the bubble's group.

isDeletable

package

isDeletable() returns boolean

Get whether this bubble is deletable or not.

Returns

boolean True if deletable.

moveDuringDrag

package

moveDuringDrag(dragSurface, newLoc)

Move this bubble during a drag, taking into account whether or not there is a drag surface.

Parameter

dragSurface

Blockly.BlockDragSurfaceSvg

The surface that carries rendered items during a drag, or null if no drag surface is in use.

newLoc

Blockly.utils.Coordinate

The location to translate to, in workspace coordinates.

Value must not be null.

moveTo

package

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.

promote

package

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

Blockly.utils.Coordinate

Absolute location.

Value must not be null.

setAutoLayout

package

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.

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.

setDragging

package

setDragging(adding)

Triggers a move callback if one exists at the end of a drag.

Parameter

adding

boolean

True if adding, false if removing.

setSvgId

setSvgId(id)

Expose the block's ID on the bubble's top-level SVG group.

Parameter

id

string

ID of block.

showContextMenu

package

showContextMenu(_e)

Show the context menu for this bubble.

Parameter

_e

Event

Mouse event.

Value must not be null.