Class: Input
Defined in: packages/blockly/core/inputs/input.ts:35
Class for an input with optional fields.
Extended by
Properties index
| Property | Description |
|---|---|
| fieldRow | - |
| align | Alignment of input's fields (left, right or centre). |
| type | - |
| connection | - |
| name | Language-neutral identifier which may used to find this input again. |
Methods index
| Method | Description |
|---|---|
| getSourceBlock | Get the source block for this input. |
| appendField | Add a field (or label from string), and all prefix and suffix fields, to the end of the input's field row. |
| insertFieldAt | Inserts a field (or label from string), and all prefix and suffix fields, at the location of the input's field row. |
| removeField | Remove a field from this input. |
| isVisible | Gets whether this input is visible or not. |
| setCheck | Change a connection's compatibility. |
| setAlign | Change the alignment of the connection's field(s). |
| setShadowDom | Changes the connection's shadow block. |
| getShadowDom | Returns the XML representation of the connection's shadow block. |
| init | Initialize the fields on this input. |
| setAriaLabelProvider | Sets a custom ARIA label provider for this input, or null if it should be reset to use the default method. |
| getAriaLabelText | 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. |
| dispose | Sever all links to this input. |
| makeConnection | 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. |
Constructors
Constructor
new Input(name, sourceBlock): Input;
Defined in: packages/blockly/core/inputs/input.ts:55
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Language-neutral identifier which may used to find this input again. |
sourceBlock | Block | The 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
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
| Parameter | Type | Description |
|---|---|---|
field | string | Field<T> | Something to add as a field. |
opt_name? | string | Language-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
| Parameter | Type | Description |
|---|---|---|
index | number | The index at which to insert field. |
field | string | Field<T> | Something to add as a field. |
opt_name? | 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.
removeField()
removeField(name, opt_quiet?): boolean;
Defined in: packages/blockly/core/inputs/input.ts:147
Remove a field from this input.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the field. |
opt_quiet? | boolean | True 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
| Parameter | Type | Description |
|---|---|---|
check | string | string[] | null | Compatible 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
| Parameter | Type | Description |
|---|---|---|
align | Align | One 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
| Parameter | Type | Description |
|---|---|---|
shadow | Element | null | DOM 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
| Parameter | Type | Description |
|---|---|---|
provider | AriaLabelProvider | null | The 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
| Parameter | Type |
|---|---|
type | ConnectionType |
Returns
a connection of the given type, which is either a headless or rendered connection, based on the type of this input's source block.