Class: Input

Constructor

Input

new Input(type, name, block, connection)

Class for an input with an optional field.

Parameter

type

number

The type of the input.

name

string

Language-neutral identifier which may used to find this input again.

block

Blockly.Block

The block containing this input.

Value must not be null.

connection

Blockly.Connection

Optional connection for this input.

Properties

align

number

Alignment of input's fields (left, right or centre).

connection

non-null Blockly.RenderedConnection

connection

Blockly.Connection

fieldRow

non-null Array of non-null Blockly.Field

name

string

sourceBlock_

non-null Blockly.BlockSvg

sourceBlock_

non-null Blockly.BlockSvg

sourceBlock_

non-null Blockly.BlockSvg

type

number

Methods

appendField

appendField(field, opt_name) returns Blockly.Input

Add a field (or label from string), and all prefix and suffix fields, to the end of the input's field row.

Parameter

field

(string or non-null Blockly.Field)

Something to add as a field.

opt_name

Optional

string

Language-neutral identifier which may used to find this field again. Should be unique to the host block.

Returns

non-null Blockly.Input The input being append to (to allow chaining).

dispose

dispose()

Sever all links to this input.

getShadowDom

getShadowDom() returns Element

Returns the xml representation of the connection's shadow block.

Returns

Element Shadow DOM representation of a block or null.

getSourceBlock

getSourceBlock() returns Blockly.Block

Get the source block for this input.

Returns

Blockly.Block The source block, or null if there is none.

init

init()

Initialize the fields on this input.

insertFieldAt

insertFieldAt(index, field, opt_name) returns number

Inserts a field (or label from string), and all prefix and suffix fields, at the location of the input's field row.

Parameter

index

number

The index at which to insert field.

field

(string or non-null Blockly.Field)

Something to add as a field.

opt_name

Optional

string

Language-neutral identifier which may used to find this field again. Should be unique to the host block.

Returns

number The index following the last inserted field.

isVisible

isVisible() returns boolean

Gets whether this input is visible or not.

Returns

boolean True if visible.

markDirty

package

markDirty()

Mark all fields on this input as dirty.

removeField

removeField(name, opt_quiet) returns boolean

Remove a field from this input.

Parameter

name

string

The name of the field.

opt_quiet

Optional

boolean

True to prevent an error if field is not present.

Throws

Error if the field is not present and opt_quiet is false.

Returns

boolean True if operation succeeds, false if field is not present and opt_quiet is true.

setAlign

setAlign(align) returns Blockly.Input

Change the alignment of the connection's field(s).

Parameter

align

number

One of Blockly.ALIGN_LEFT, ALIGN_CENTRE, ALIGN_RIGHT. In RTL mode directions are reversed, and ALIGN_RIGHT aligns to the left.

Returns

non-null Blockly.Input The input being modified (to allow chaining).

setCheck

setCheck(check) returns Blockly.Input

Change a connection's compatibility.

Parameter

check

(string, Array of string, or null)

Compatible value type or list of value types. Null if all types are compatible.

Returns

non-null Blockly.Input The input being modified (to allow chaining).

setShadowDom

setShadowDom(shadow) returns Blockly.Input

Changes the connection's shadow block.

Parameter

shadow

Element

DOM representation of a block or null.

Returns

Blockly.Input The input being modified (to allow chaining).

setVisible

package

setVisible(visible) returns Array of non-null Blockly.BlockSvg

Sets whether this input is visible or not. Should only be used to collapse/uncollapse a block.

Parameter

visible

boolean

True if visible.

Returns

non-null Array of non-null Blockly.BlockSvg List of blocks to render.