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

string

id

string

isComment

package

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

package   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

package   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

package   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

package

dispose()

Dispose of this comment.

getContent

package

getContent() returns string

Returns this comment's text.

Returns

string Comment text.

getHeight

package

getHeight() returns number

Get comment height.

Returns

number Comment height.

getWidth

package

getWidth() returns number

Get comment width.

Returns

number Comment width.

getXY

package

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

package

isDeletable() returns boolean

Get whether this comment is deletable or not.

Returns

boolean True if deletable.

isMovable

package

isMovable() returns boolean

Get whether this comment is movable or not.

Returns

boolean True if movable.

moveBy

package

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

package

setContent(content)

Set this comment's content.

Parameter

content

string

Comment content.

setDeletable

package

setDeletable(deletable)

Set whether this comment is deletable or not.

Parameter

deletable

boolean

True if deletable.

setHeight

package

setHeight(height)

Set comment height.

Parameter

height

number

Comment height.

setMovable

package

setMovable(movable)

Set whether this comment is movable or not.

Parameter

movable

boolean

True if movable.

setWidth

package

setWidth(width)

Set comment width.

Parameter

width

number

comment width.

toXml

package

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

package

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.