blockly > ConnectionChecker > canConnectWithReason

ConnectionChecker.canConnectWithReason() 方法

检查当前连接是否可以与目标连接连接,如果出现问题,则返回错误代码。

Signature:

canConnectWithReason(a: Connection | null, b: Connection | null, isDragging: boolean, opt_distance?: number): number;

参数

参数 类型 说明
a 连接 | null 要检查其兼容性的连接。
b 连接 | null 要检查其兼容性的连接。
isDragging boolean 如果通过拖动块建立连接,则为 true。
opt_distance number (可选)拖动检查中连接点之间允许的最大距离。

返回

number

如果连接合法,则为 Connection.CAN_CONNECT,否则为错误代码。