Blockly. ConnectionChecker
Constructor
ConnectionChecker
new ConnectionChecker()
Class for connection type checking logic.
- Implements
- Blockly.IConnectionChecker
Methods
canConnect
canConnect(a, b, isDragging, opt_distance) returns boolean
Check whether the current connection can connect with the target connection.
Parameter |
|
---|---|
a |
Connection to check compatibility with. |
b |
Connection to check compatibility with. |
isDragging |
boolean True if the connection is being made by dragging a block. |
opt_distance |
Optional number The max allowable distance between the connections for drag checks. |
- Implements
- Blockly.IConnectionChecker#canConnect
- Returns
-
boolean
Whether the connection is legal.
canConnectToPrevious_
canConnectToPrevious_(a, b) returns boolean
Helper function for drag checking.
Parameter |
|
---|---|
a |
The connection to check, which must be a statement input or next connection. Value must not be null. |
b |
A nearby connection to check, which must be a previous connection. Value must not be null. |
- Returns
-
boolean
True if the connection is allowed, false otherwise.
canConnectWithReason
canConnectWithReason(a, b, isDragging, opt_distance) returns number
Checks whether the current connection can connect with the target connection, and return an error code if there are problems.
Parameter |
|
---|---|
a |
Connection to check compatibility with. |
b |
Connection to check compatibility with. |
isDragging |
boolean True if the connection is being made by dragging a block. |
opt_distance |
Optional number The max allowable distance between the connections for drag checks. |
- Implements
- Blockly.IConnectionChecker#canConnectWithReason
- Returns
-
number
Blockly.Connection.CAN_CONNECT if the connection is legal, an error code otherwise.
doDragChecks
doDragChecks(a, b, distance) returns boolean
Check whether this connection can be made by dragging.
Parameter |
|
---|---|
a |
Connection to compare. Value must not be null. |
b |
Connection to compare against. Value must not be null. |
distance |
number The maximum allowable distance between connections. |
- Implements
- Blockly.IConnectionChecker#doDragChecks
- Returns
-
boolean
True if the connection is allowed during a drag.
doSafetyChecks
doSafetyChecks(a, b) returns number
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).
Parameter |
|
---|---|
a |
The first of the connections to check. |
b |
The second of the connections to check. |
- Implements
- Blockly.IConnectionChecker#doSafetyChecks
- Returns
-
number
An enum with the reason this connection is safe or unsafe.
doTypeChecks
doTypeChecks(a, b) returns boolean
Check whether this connection is compatible with another connection with respect to the value type system. E.g. square_root("Hello") is not compatible.
Parameter |
|
---|---|
a |
Connection to compare. Value must not be null. |
b |
Connection to compare against. Value must not be null. |
- Implements
- Blockly.IConnectionChecker#doTypeChecks
- Returns
-
boolean
True if the connections share a type.
getErrorMessage
getErrorMessage(errorCode, a, b) returns string
Helper method that translates a connection error code into a string.
Parameter |
|
---|---|
errorCode |
number The error code. |
a |
One of the two connections being checked. |
b |
The second of the two connections being checked. |
- Implements
- Blockly.IConnectionChecker#getErrorMessage
- Returns
-
string
A developer-readable error string.