blockly > IConnectionChecker
IConnectionChecker interface
Class for connection type checking logic.
Signature:
export interface IConnectionChecker
Methods
Method |
Description |
canConnect(a, b, isDragging, opt_distance) |
Check whether the current connection can connect with the target connection. |
canConnectWithReason(a, b, isDragging, opt_distance) |
Checks whether the current connection can connect with the target connection, and return an error code if there are problems. |
doDragChecks(a, b, distance) |
Check whether this connection can be made by dragging. |
doSafetyChecks(a, b) |
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(a, b) |
Check whether this connection is compatible with another connection with respect to the value type system. E.g. square_root("Hello") is not compatible. |
getErrorMessage(errorCode, a, b) |
Helper method that translates a connection error code into a string. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `IConnectionChecker` interface defines the logic for validating connections between blocks in Blockly."],["It provides methods to check connection compatibility, including type checks, safety checks, and drag checks."],["`IConnectionChecker` helps ensure that connections adhere to Blockly's rules and prevent invalid block configurations."],["Developers can use `IConnectionChecker` methods to determine if two connections can be connected and understand the reasons for any connection failures."]]],["The `IConnectionChecker` interface defines methods for validating connections in a visual programming environment. It allows checking if two connections (`a` and `b`) can connect, with or without error codes using `canConnect` and `canConnectWithReason`. Dragging connections are validated via `doDragChecks`. `doSafetyChecks` verifies the safety of a connection, while `doTypeChecks` confirms compatibility based on value types. `getErrorMessage` converts error codes into user-friendly messages.\n"]]