Skip to main content

Class: Input

Defined in: packages/blockly/core/inputs/input.ts:35

Class for an input with optional fields.

Extended by

Properties index

PropertyDescription
fieldRow-
alignAlignment of input's fields (left, right or centre).
type-
connection-
nameLanguage-neutral identifier which may used to find this input again.

Methods index

MethodDescription
getSourceBlockGet the source block for this input.
appendFieldAdd a field (or label from string), and all prefix and suffix fields, to the end of the input's field row.
insertFieldAtInserts a field (or label from string), and all prefix and suffix fields, at the location of the input's field row.
removeFieldRemove a field from this input.
isVisibleGets whether this input is visible or not.
setCheckChange a connection's compatibility.
setAlignChange the alignment of the connection's field(s).
setShadowDomChanges the connection's shadow block.
getShadowDomReturns the XML representation of the connection's shadow block.
initInitialize the fields on this input.
setAriaLabelProviderSets a custom ARIA label provider for this input, or null if it should be reset to use the default method.
getAriaLabelTextReturns the string from the custom ARIA label provider set, or null if the default label (from the field row) should be used. See setAriaLabelProvider for more context.
disposeSever all links to this input.
makeConnectionConstructs a connection based on the type of this input's source block. Properly handles constructing headless connections for headless blocks and rendered connections for rendered blocks.

Constructors

Constructor

new Input(name, sourceBlock): Input;

Defined in: packages/blockly/core/inputs/input.ts:55

Parameters

ParameterTypeDescription
namestringLanguage-neutral identifier which may used to find this input again.
sourceBlockBlockThe block containing this input.

Returns

Input

Properties

fieldRow

fieldRow: Field<any>[] = [];

Defined in: packages/blockly/core/inputs/input.ts:36


align

align: Align = Align.LEFT;

Defined in: packages/blockly/core/inputs/input.ts:38

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


type

readonly type: inputTypes = inputTypes.CUSTOM;

Defined in: packages/blockly/core/inputs/input.ts:46


connection

connection: Connection | null = null;

Defined in: packages/blockly/core/inputs/input.ts:48


name

name: string;

Defined in: packages/blockly/core/inputs/input.ts:56

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

Methods

getSourceBlock()

getSourceBlock(): Block;

Defined in: packages/blockly/core/inputs/input.ts:65

Get the source block for this input.

Returns

Block

The block this input is part of.


appendField()

appendField<T>(field, opt_name?): Input;

Defined in: packages/blockly/core/inputs/input.ts:78

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

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
fieldstring | Field<T>Something to add as a field.
opt_name?stringLanguage-neutral identifier which may used to find this field again. Should be unique to the host block.

Returns

Input

The input being append to (to allow chaining).


insertFieldAt()

insertFieldAt<T>(
index,
field,
opt_name?
): number;

Defined in: packages/blockly/core/inputs/input.ts:93

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

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
indexnumberThe index at which to insert field.
fieldstring | Field<T>Something to add as a field.
opt_name?stringLanguage-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.


removeField()

removeField(name, opt_quiet?): boolean;

Defined in: packages/blockly/core/inputs/input.ts:147

Remove a field from this input.

Parameters

ParameterTypeDescription
namestringThe name of the field.
opt_quiet?booleanTrue to prevent an error if field is not present.

Returns

boolean

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

Throws

if the field is not present and opt_quiet is false.


isVisible()

isVisible(): boolean;

Defined in: packages/blockly/core/inputs/input.ts:169

Gets whether this input is visible or not.

Returns

boolean

True if visible.


setCheck()

setCheck(check): Input;

Defined in: packages/blockly/core/inputs/input.ts:227

Change a connection's compatibility.

Parameters

ParameterTypeDescription
checkstring | string[] | nullCompatible value type or list of value types. Null if all types are compatible.

Returns

Input

The input being modified (to allow chaining).


setAlign()

setAlign(align): Input;

Defined in: packages/blockly/core/inputs/input.ts:242

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

Parameters

ParameterTypeDescription
alignAlignOne of the values of Align. In RTL mode directions are reversed, and Align.RIGHT aligns to the left.

Returns

Input

The input being modified (to allow chaining).


setShadowDom()

setShadowDom(shadow): Input;

Defined in: packages/blockly/core/inputs/input.ts:257

Changes the connection's shadow block.

Parameters

ParameterTypeDescription
shadowElement | nullDOM representation of a block or null.

Returns

Input

The input being modified (to allow chaining).


getShadowDom()

getShadowDom(): Element | null;

Defined in: packages/blockly/core/inputs/input.ts:270

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

Returns

Element | null

Shadow DOM representation of a block or null.


init()

init(): void;

Defined in: packages/blockly/core/inputs/input.ts:278

Initialize the fields on this input.

Returns

void


setAriaLabelProvider()

setAriaLabelProvider(provider): Input;

Defined in: packages/blockly/core/inputs/input.ts:301

Sets a custom ARIA label provider for this input, or null if it should be reset to use the default method.

Inputs do not compute ARIA contexts directly, so the set provider will be used in select cases when the Input needs to be represented (such as for parts of a block label or for connections). Note that overriding this provider will not recompute any already constructed ARIA labels, and it cannot be assumed that the provider will be called any particular number of times during label recomputation. As such, implementations should make sure to provide a deterministic and idempotent ARIA representation each time the provider is called for a given input. It's also fine to reuse providers across multiple Input implementations.

Parameters

ParameterTypeDescription
providerAriaLabelProvider | nullThe string or function to use to set the ARIA label for the input

Returns

Input

The input being modified (to allow chaining).


getAriaLabelText()

getAriaLabelText(): string | null;

Defined in: packages/blockly/core/inputs/input.ts:310

Returns the string from the custom ARIA label provider set, or null if the default label (from the field row) should be used. See setAriaLabelProvider for more context.

Returns

string | null


dispose()

dispose(): void;

Defined in: packages/blockly/core/inputs/input.ts:343

Sever all links to this input.

Returns

void


makeConnection()

protected makeConnection(type): Connection;

Defined in: packages/blockly/core/inputs/input.ts:360

Constructs a connection based on the type of this input's source block. Properly handles constructing headless connections for headless blocks and rendered connections for rendered blocks.

Parameters

ParameterType
typeConnectionType

Returns

Connection

a connection of the given type, which is either a headless or rendered connection, based on the type of this input's source block.