Constructor

FieldAngle

new FieldAngle(opt_value, opt_validator)

Class for an editable angle field.

Parameter

opt_value

Optional

(string or number)

The initial content of the field. The value should cast to a number, and if it does not, '0' will be used.

opt_validator

Optional

function()

An optional function that is called to validate any constraints on what the user entered. Takes the new text as an argument and returns the accepted text or null to abort the change.

Extends
Blockly.FieldTextInput

Properties

CLOCKWISE

static

Angle increases clockwise (true) or counterclockwise (false).

HALF

static

Half the width of protractor image.

OFFSET

static

Offset the location of 0 degrees (and all angles) by a constant. Usually either 0 (0 = right) or 90 (0 = up).

RADIUS

static

Radius of protractor circle. Slightly smaller than protractor size since otherwise SVG crops off half the border at the edges.

ROUND

static

Round angles to the nearest 15 degrees when using mouse. Set to 0 to disable rounding.

WRAP

static

Maximum allowed angle before wrapping. Usually either 360 (for 0 to 359.9) or 180 (for -179.9 to 180).

CURSOR

Mouse cursor style when over the hotspot that initiates the editor.

Inherited from
Blockly.FieldTextInput#CURSOR

EDITABLE

Editable fields are saved by the XML renderer, non-editable fields are not.

Inherited from
Blockly.Field#EDITABLE

maxDisplayLength

unknown

Maximum characters of text to display before adding an ellipsis.

Inherited from
Blockly.Field#maxDisplayLength

name

unknown

Name of field. Unique within each block. Static labels are usually unnamed.

Inherited from
Blockly.Field#name

textElement_

unknown

Inherited from
Blockly.Field#textElement_

Methods

fromJson

static

fromJson(options) returns Blockly.FieldAngle

Construct a FieldAngle from a JSON arg object.

Parameter

options

Object

A JSON object with options (angle).

Value must not be null.

Returns

non-null Blockly.FieldAngle The new field instance.

callValidator

callValidator(text) returns string

Calls the validation function for this field, as well as all the validation function for the field's class and its parents.

Parameter

text

Proposed text.

Inherited from
Blockly.Field#callValidator
Returns

Revised text, or null if invalid.

classValidator

classValidator(text) returns string

Ensure that only an angle may be entered.

Parameter

text

string

The user's text.

Returns

nullable string A string representing a valid angle, or null if invalid.

dispose

dispose()

Close the input widget if this input is being deleted.

Inherited from
Blockly.FieldTextInput#dispose

forceRerender

forceRerender()

Force a rerender of the block that this field is installed on, which will rerender this field and adjust for any sizing changes. Other fields on the same block will not rerender, because their sizes have already been recorded.

Inherited from
Blockly.Field#forceRerender

getSize

getSize() returns goog.math.Size

Returns the height and width of the field.

Inherited from
Blockly.Field#getSize
Returns

Height and width.

getSvgRoot

getSvgRoot() returns Element

Gets the group element for this editable field. Used for measuring the size and for positioning.

Inherited from
Blockly.Field#getSvgRoot
Returns

The group element.

getText

getText() returns string

Get the text from this field.

Inherited from
Blockly.Field#getText
Returns

Current text.

getValidator

getValidator() returns function()

Gets the validation function for editable fields.

Inherited from
Blockly.Field#getValidator
Returns

Validation function, or null.

getValue

getValue() returns string

By default there is no difference between the human-readable text and the language-neutral values. Subclasses (such as dropdown) may define this.

Inherited from
Blockly.Field#getValue
Returns

Current value.

init

init()

Install this field on a block.

Inherited from
Blockly.Field#init

initModel

initModel()

Initializes the model of the field after it has been installed on a block. No-op by default.

Inherited from
Blockly.Field#initModel

isCurrentlyEditable

isCurrentlyEditable() returns boolean

Check whether this field is currently editable. Some fields are never editable (e.g. text labels). Those fields are not serialized to XML. Other fields may be editable, and therefore serialized, but may exist on non-editable blocks.

Inherited from
Blockly.Field#isCurrentlyEditable
Returns

whether this field is editable and on an editable block

isVisible

isVisible() returns boolean

Gets whether this editable field is visible or not.

Inherited from
Blockly.Field#isVisible
Returns

True if visible.

onMouseMove

onMouseMove(e)

Set the angle to match the mouse's position.

Parameter

e

Event

Mouse move event.

Value must not be null.

referencesVariables

referencesVariables() returns boolean

Whether this field references any Blockly variables. If true it may need to be handled differently during serialization and deserialization. Subclasses may override this.

Inherited from
Blockly.Field#referencesVariables
Returns

True if this field has any variable references.

setSourceBlock

setSourceBlock(block)

Attach this field to a block.

Parameter

block

The block containing this field.

Value must not be null.

Inherited from
Blockly.Field#setSourceBlock

setSpellcheck

setSpellcheck(check)

Set whether this field is spellchecked by the browser.

Parameter

check

True if checked.

Inherited from
Blockly.FieldTextInput#setSpellcheck

setText

setText(text)

Insert a degree symbol.

Parameter

text

string

New text.

Value may be null.

setTooltip

setTooltip(_newTip)

Change the tooltip text for this field.

Parameter

_newTip

Text for tooltip or a parent element to link to for its tooltip.

Inherited from
Blockly.Field#setTooltip

setValidator

setValidator(handler)

Sets a new validation function for editable fields.

Parameter

handler

New validation function, or null.

Inherited from
Blockly.Field#setValidator

setValue

setValue(newValue)

By default there is no difference between the human-readable text and the language-neutral values. Subclasses (such as dropdown) may define this.

Parameter

newValue

New value.

Inherited from
Blockly.Field#setValue

setVisible

setVisible(visible)

Sets whether this editable field is visible or not.

Parameter

visible

True if visible.

Inherited from
Blockly.Field#setVisible

updateEditable

updateEditable()

Add or remove the UI indicating if this field is editable or not.

Inherited from
Blockly.Field#updateEditable

updateWidth

updateWidth()

Updates thw width of the field. This calls getCachedWidth which won't cache the approximated width on IE/Edge when getComputedTextLength fails. Once it eventually does succeed, the result will be cached.

Inherited from
Blockly.Field#updateWidth