Constructor

WorkspaceComment

new WorkspaceComment(workspace, content, height, width, opt_id)

Class for a workspace comment.

Parameter

workspace

Blockly.Workspace

The block's workspace.

Value must not be null.

content

string

The content of this workspace comment.

height

number

Height of the comment.

width

number

Width of the comment.

opt_id

Optional

string

Optional ID. Use this ID if provided, otherwise create a new ID.

Properties

content_

protected

non-null string

id

string

isComment

boolean

RTL

protected

boolean

workspace

non-null Blockly.Workspace

xy_

protected

non-null goog.math.Coordinate

The comment's position in workspace units. (0, 0) is at the workspace's origin; scale does not change this value.

Methods

fireCreateEvent

static

fireCreateEvent(comment)

Fire a create event for the given workspace comment, if comments are enabled.

Parameter

comment

Blockly.WorkspaceComment

The comment that was just created.

Value must not be null.

fromXml

static

fromXml(xmlComment, workspace) returns Blockly.WorkspaceComment

Decode an XML comment tag and create a comment on the workspace.

Parameter

xmlComment

Element

XML comment element.

Value must not be null.

workspace

Blockly.Workspace

The workspace.

Value must not be null.

Returns

non-null Blockly.WorkspaceComment The created workspace comment.

parseAttributes

static

parseAttributes(xml) returns Object

Decode an XML comment tag and return the results in an object.

Parameter

xml

Element

XML comment element.

Value must not be null.

Returns

{w: number, h: number, x: number, y: number, content: string} An object containing the id, size, position, and comment string.

dispose

dispose()

Dispose of this comment.

getContent

getContent() returns string

Returns this comment's text.

Returns

string Comment text.

getHeight

getHeight() returns number

Get comment height.

Returns

number comment height.

getWidth

getWidth() returns number

Get comment width.

Returns

number comment width.

getXY

getXY() returns goog.math.Coordinate

Get stored location.

Returns

non-null goog.math.Coordinate The comment's stored location. This is not valid if the comment is currently being dragged.

isDeletable

isDeletable() returns boolean

Get whether this comment is deletable or not.

Returns

boolean True if deletable.

isMovable

isMovable() returns boolean

Get whether this comment is movable or not.

Returns

boolean True if movable.

moveBy

moveBy(dx, dy)

Move a comment by a relative offset.

Parameter

dx

number

Horizontal offset, in workspace units.

dy

number

Vertical offset, in workspace units.

setContent

setContent(content)

Set this comment's content.

Parameter

content

string

Comment content.

setDeletable

setDeletable(deletable)

Set whether this comment is deletable or not.

Parameter

deletable

boolean

True if deletable.

setHeight

setHeight(height)

Set comment height.

Parameter

height

number

comment height.

setMovable

setMovable(movable)

Set whether this comment is movable or not.

Parameter

movable

boolean

True if movable.

setWidth

setWidth(width)

Set comment width.

Parameter

width

number

comment width.

toXml

toXml(opt_noId) returns Element

Encode a comment subtree as XML, but don't serialize the XY coordinates. This method avoids some expensive metrics-related calls that are made in toXmlWithXY().

Parameter

opt_noId

Optional

boolean

True if the encoder should skip the comment id.

Returns

non-null Element Tree of XML elements.

toXmlWithXY

toXmlWithXY(opt_noId) returns Element

Encode a comment subtree as XML with XY coordinates.

Parameter

opt_noId

Optional

boolean

True if the encoder should skip the comment id.

Returns

non-null Element Tree of XML elements.