Interface: IConnectionChecker
Defined in: packages/blockly/core/interfaces/i_connection_checker.ts:15
Class for connection type checking logic.
Methods index
| Method | Description |
|---|---|
| canConnect | Check whether the current connection can connect with the target connection. |
| canConnectWithReason | Checks whether the current connection can connect with the target connection, and return an error code if there are problems. |
| getErrorMessage | Helper method that translates a connection error code into a string. |
| doSafetyChecks | Check that connecting the given connections is safe, meaning that it would not break any of Blockly's basic assumptions (e.g. no self connections). |
| doTypeChecks | Check whether this connection is compatible with another connection with respect to the value type system. E.g. square_root("Hello") is not compatible. |
| doDragChecks | Check whether this connection can be made by dragging. |
Methods
canConnect()
canConnect(
a,
b,
isDragging,
opt_distance?
): boolean;
Defined in: packages/blockly/core/interfaces/i_connection_checker.ts:27
Check whether the current connection can connect with the target connection.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Connection | null | Connection to check compatibility with. |
b | Connection | null | Connection to check compatibility with. |
isDragging | boolean | True if the connection is being made by dragging a block. |
opt_distance? | number | The max allowable distance between the connections for drag checks. |
Returns
boolean
Whether the connection is legal.
canConnectWithReason()
canConnectWithReason(
a,
b,
isDragging,
opt_distance?
): number;
Defined in: packages/blockly/core/interfaces/i_connection_checker.ts:46
Checks whether the current connection can connect with the target connection, and return an error code if there are problems.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Connection | null | Connection to check compatibility with. |
b | Connection | null | Connection to check compatibility with. |
isDragging | boolean | True if the connection is being made by dragging a block. |
opt_distance? | number | The max allowable distance between the connections for drag checks. |
Returns
number
Connection.CAN_CONNECT if the connection is legal, an error code otherwise.
getErrorMessage()
getErrorMessage(
errorCode,
a,
b
): string;
Defined in: packages/blockly/core/interfaces/i_connection_checker.ts:61
Helper method that translates a connection error code into a string.
Parameters
| Parameter | Type | Description |
|---|---|---|
errorCode | number | The error code. |
a | Connection | null | One of the two connections being checked. |
b | Connection | null | The second of the two connections being checked. |
Returns
string
A developer-readable error string.
doSafetyChecks()
doSafetyChecks(a, b): number;
Defined in: packages/blockly/core/interfaces/i_connection_checker.ts:75
Check that connecting the given connections is safe, meaning that it would not break any of Blockly's basic assumptions (e.g. no self connections).
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Connection | null | The first of the connections to check. |
b | Connection | null | The second of the connections to check. |
Returns
number
An enum with the reason this connection is safe or unsafe.
doTypeChecks()
doTypeChecks(a, b): boolean;
Defined in: packages/blockly/core/interfaces/i_connection_checker.ts:86
Check whether this connection is compatible with another connection with respect to the value type system. E.g. square_root("Hello") is not compatible.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Connection | Connection to compare. |
b | Connection | Connection to compare against. |
Returns
boolean
True if the connections share a type.
doDragChecks()
doDragChecks(
a,
b,
distance
): boolean;
Defined in: packages/blockly/core/interfaces/i_connection_checker.ts:96
Check whether this connection can be made by dragging.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | RenderedConnection | Connection to compare. |
b | RenderedConnection | Connection to compare against. |
distance | number | The maximum allowable distance between connections. |
Returns
boolean
True if the connection is allowed during a drag.