Blockly 于 2025 年 11 月 10 日移至 Raspberry Pi Foundation!请阅读博文和常见问题解答。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
blockly > ConnectionChecker > canConnect
ConnectionChecker.canConnect() 方法
检查当前连接能否与目标连接建立连接。
Signature:
canConnect(a: Connection | null, b: Connection | null, isDragging: boolean, opt_distance?: number): boolean;
参数
| 参数 |
类型 |
说明 |
| a |
连接 | null |
用于检查兼容性的连接。 |
| b |
连接 | null |
要检查兼容性的连接。 |
| isDragging |
布尔值 |
如果连接是通过拖动块进行的,则为 true。 |
| opt_distance |
数值 |
(可选)拖动检查连接之间允许的最长距离。 |
返回:
布尔值
连接是否合法。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],["The `canConnect` method in `ConnectionChecker` verifies if two connections (`a` and `b`) are compatible. It takes two connection objects, a boolean (`isDragging`) indicating if a block is being dragged, and an optional `opt_distance` parameter for drag distance checks. It returns a boolean value indicating whether the connection between the provided connections is permitted. The method determines if it's valid for connections 'a' and 'b' to be linked.\n"]]