Constructor

Connection

new Connection(source, type)

Class for a connection between blocks.

Parameter

source

Blockly.Block

The block establishing this connection.

Value must not be null.

type

number

The type of the connection.

Properties

CAN_CONNECT

static

Constants for checking whether two connections are compatible.

db_

protected

Blockly.ConnectionDB

Connection database for connections of this type on the current workspace.

dbOpposite_

protected

Blockly.ConnectionDB

Connection database for connections compatible with this type on the current workspace.

hidden_

protected

boolean

Whether this connections is hidden (not tracked in a database) or not.

inDB_

protected

boolean

Has this connection been added to the connection database?

sourceBlock_

protected

non-null Blockly.Block

targetConnection

Blockly.Connection

Connection this connection connects to. Null if not connected.

type

number

x_

protected

number

Horizontal location of this connection.

y_

protected

number

Vertical location of this connection.

Methods

checkType_

protected

checkType_(otherConnection) returns boolean

Is this connection compatible with another connection with respect to the value type system. E.g. square_root("Hello") is not compatible.

Parameter

otherConnection

Blockly.Connection

Connection to compare against.

Value must not be null.

Returns

boolean True if the connections share a type.

connect

connect(otherConnection)

Connect this connection to another connection.

Parameter

otherConnection

Blockly.Connection

Connection to connect to.

Value must not be null.

connect_

protected

connect_(childConnection)

Connect two connections together. This is the connection on the superior block.

Parameter

childConnection

Blockly.Connection

Connection on inferior block.

Value must not be null.

disconnect

disconnect()

Disconnect this connection.

disconnectInternal_

protected

disconnectInternal_(parentBlock, childBlock)

Disconnect two blocks that are connected by this connection.

Parameter

parentBlock

Blockly.Block

The superior block.

Value must not be null.

childBlock

Blockly.Block

The inferior block.

Value must not be null.

dispose

dispose()

Sever all links to this connection (not including from the source object).

getCheck

public

getCheck() returns Array

Get a connection's compatibility.

Returns

Array List of compatible value types. Null if all types are compatible.

getShadowDom

getShadowDom() returns Element

Return a connection's shadow block.

Returns

Element shadow DOM representation of a block or null.

getSourceBlock

getSourceBlock() returns Blockly.Block

Get the source block for this connection.

Returns

Blockly.Block The source block, or null if there is none.

isConnected

isConnected() returns boolean

Is the connection connected?

Returns

boolean True if connection is connected to another connection.

isConnectionAllowed

isConnectionAllowed(candidate) returns boolean

Check if the two connections can be dragged to connect to each other.

Parameter

candidate

Blockly.Connection

A nearby connection to check.

Value must not be null.

Returns

boolean True if the connection is allowed, false otherwise.

isSuperior

isSuperior() returns boolean

Does the connection belong to a superior block (higher in the source stack)?

Returns

boolean True if connection faces down or right.

respawnShadow_

protected

respawnShadow_()

Respawn the shadow block if there was one connected to the this connection.

setCheck

setCheck(check) returns Blockly.Connection

Change a connection's compatibility.

Parameter

check

any type

Compatible value type or list of value types. Null if all types are compatible.

Returns

non-null Blockly.Connection The connection being modified (to allow chaining).

setShadowDom

setShadowDom(shadow)

Change a connection's shadow block.

Parameter

shadow

Element

DOM representation of a block or null.

targetBlock

targetBlock() returns Blockly.Block

Returns the block that this connection connects to.

Returns

Blockly.Block The connected block or null if none is connected.

toString

toString() returns string

This method returns a string describing this Connection in developer terms (English only). Intended to on be used in console logs and errors.

Returns

string The description.