Skip to main content

Class: StrictConnectionChecker

Defined in: plugins/strict-connection-checker/src/index.js:25

A connection checker that imposes stricter typing rules than the default checker in Blockly, but uses the same rules for dragging and safety. This checker still expects nullable arrays of string for connection type checks, and still looks for intersections in the arrays. Unlike the default checker, null checks arrays are only compatible with other null arrays.

Implements​

Extends​

  • ConnectionChecker

Methods index​

MethodDescription
canConnectCheck whether the current connection can connect with the target connection.
canConnectToPrevious_Helper function for drag checking.
canConnectWithReasonChecks whether the current connection can connect with the target connection, and return an error code if there are problems.
doDragChecksCheck whether this connection can be made by dragging.
doSafetyChecksCheck that connecting the given connections is safe, meaning that it would not break any of Blockly's basic assumptions (e.g. no self connections).
doTypeChecksType check arrays must either intersect or both be null.
getErrorMessageHelper method that translates a connection error code into a string.

Constructors​

Constructor​

new StrictConnectionChecker(): StrictConnectionChecker;

Defined in: plugins/strict-connection-checker/src/index.js:29

Constructor for the connection checker.

Returns​

StrictConnectionChecker

Overrides​

Blockly.ConnectionChecker.constructor

Methods​

canConnect()​

canConnect(
a,
b,
isDragging,
opt_distance?
): boolean;

Check whether the current connection can connect with the target connection.

Parameters​

ParameterTypeDescription
aConnection | nullConnection to check compatibility with.
bConnection | nullConnection to check compatibility with.
isDraggingbooleanTrue if the connection is being made by dragging a block.
opt_distance?numberThe max allowable distance between the connections for drag checks.

Returns​

boolean

Whether the connection is legal.

Inherited from​

Blockly.ConnectionChecker.canConnect


canConnectToPrevious_()​

protected canConnectToPrevious_(a, b): boolean;

Helper function for drag checking.

Parameters​

ParameterTypeDescription
aConnectionThe connection to check, which must be a statement input or next connection.
bConnectionA nearby connection to check, which must be a previous connection.

Returns​

boolean

True if the connection is allowed, false otherwise.

Inherited from​

Blockly.ConnectionChecker.canConnectToPrevious_


canConnectWithReason()​

canConnectWithReason(
a,
b,
isDragging,
opt_distance?
): number;

Checks whether the current connection can connect with the target connection, and return an error code if there are problems.

Parameters​

ParameterTypeDescription
aConnection | nullConnection to check compatibility with.
bConnection | nullConnection to check compatibility with.
isDraggingbooleanTrue if the connection is being made by dragging a block.
opt_distance?numberThe max allowable distance between the connections for drag checks.

Returns​

number

Connection.CAN_CONNECT if the connection is legal, an error code otherwise.

Inherited from​

Blockly.ConnectionChecker.canConnectWithReason


doDragChecks()​

doDragChecks(
a,
b,
distance
): boolean;

Check whether this connection can be made by dragging.

Parameters​

ParameterTypeDescription
aRenderedConnectionConnection to compare (on the block that's being dragged).
bRenderedConnectionConnection to compare against.
distancenumberThe maximum allowable distance between connections.

Returns​

boolean

True if the connection is allowed during a drag.

Inherited from​

Blockly.ConnectionChecker.doDragChecks


doSafetyChecks()​

doSafetyChecks(a, b): 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).

Parameters​

ParameterTypeDescription
aConnection | nullThe first of the connections to check.
bConnection | nullThe second of the connections to check.

Returns​

number

An enum with the reason this connection is safe or unsafe.

Inherited from​

Blockly.ConnectionChecker.doSafetyChecks


doTypeChecks()​

doTypeChecks(a, b): boolean;

Defined in: plugins/strict-connection-checker/src/index.js:37

Type check arrays must either intersect or both be null.

Parameters​

ParameterType
aany
bany

Returns​

boolean

Overrides​

Blockly.ConnectionChecker.doTypeChecks


getErrorMessage()​

getErrorMessage(
errorCode,
a,
b
): string;

Helper method that translates a connection error code into a string.

Parameters​

ParameterTypeDescription
errorCodenumberThe error code.
aConnection | nullOne of the two connections being checked.
bConnection | nullThe second of the two connections being checked.

Returns​

string

A developer-readable error string.

Inherited from​

Blockly.ConnectionChecker.getErrorMessage