Class: RenderedConnection

Constructor

RenderedConnection

new RenderedConnection(source, type)

Class for a connection between blocks that may be rendered on screen.

Parameter

source

Blockly.BlockSvg

The block establishing this connection.

Value must not be null.

type

number

The type of the connection.

Extends
Blockly.Connection

Enumeration

TrackedState

static

number

Enum for different kinds of tracked states.

WILL_TRACK means that this connection will add itself to the db on the next moveTo call it receives.

UNTRACKED means that this connection will not add itself to the database until setTracking(true) is explicitly called.

TRACKED means that this connection is currently being tracked.

Value

WILL_TRACK

UNTRACKED

TRACKED

Properties

TrackedState

static

number

Enum for different kinds of tracked states.

WILL_TRACK means that this connection will add itself to the db on the next moveTo call it receives.

UNTRACKED means that this connection will not add itself to the database until setTracking(true) is explicitly called.

TRACKED means that this connection is currently being tracked.

Value

WILL_TRACK

UNTRACKED

TRACKED

disposed

package

unknown

Has this connection been disposed of?

Inherited from
Blockly.Connection#disposed

sourceBlock_

non-null Blockly.BlockSvg

targetConnection

Blockly.RenderedConnection

Connection this connection connects to. Null if not connected.

type

unknown

Inherited from
Blockly.Connection#type

x

package

unknown

Horizontal location of this connection.

Inherited from
Blockly.Connection#x

y

package

unknown

Vertical location of this connection.

Inherited from
Blockly.Connection#y

Methods

bumpAwayFrom

package

bumpAwayFrom(staticConnection)

Move the block(s) belonging to the connection to a point where they don't visually interfere with the specified connection.

Parameter

staticConnection

Blockly.Connection

The connection to move away from.

Value must not be null.

canConnectWithReason

canConnectWithReason(target) returns number

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

Parameter

target

Connection to check compatibility with.

Inherited from
Blockly.Connection#canConnectWithReason
Returns

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

checkConnection

package

checkConnection(target)

Checks whether the current connection and target connection are compatible and throws an exception if they are not.

Parameter

target

The connection to check compatibility with.

Inherited from
Blockly.Connection#checkConnection

checkType

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

Connection to compare against.

Value must not be null.

Inherited from
Blockly.Connection#checkType
Returns

True if the connections share a type.

closest

closest(maxLimit, dxy) returns Object

Find the closest compatible connection to this connection. All parameters are in workspace units.

Parameter

maxLimit

number

The maximum radius to another connection.

dxy

Blockly.utils.Coordinate

Offset between this connection's location in the database and the current location (as a result of dragging).

Value must not be null.

Returns

non-null {connection: nullable Blockly.Connection, radius: number} Contains two properties: 'connection' which is either another connection or null, and 'radius' which is the distance.

connect

connect(otherConnection)

Connect this connection to another connection.

Parameter

otherConnection

Connection to connect to.

Value must not be null.

Inherited from
Blockly.Connection#connect

connect_

protected

connect_(childConnection)

Connect two connections together. This is the connection on the superior block. Rerender blocks as needed.

Parameter

childConnection

Blockly.Connection

Connection on inferior block.

Value must not be null.

disconnect

disconnect()

Disconnect this connection.

Inherited from
Blockly.Connection#disconnect

dispose

package

dispose()

Dispose of this connection. Remove it from the database (if it is tracked) and call the super-function to deal with connected blocks.

Inherited from
Blockly.RenderedConnection#dispose

distanceFrom

distanceFrom(otherConnection) returns number

Returns the distance between this connection and another connection in workspace units.

Parameter

otherConnection

Blockly.Connection

The other connection to measure the distance to.

Value must not be null.

Returns

number The distance between connections, in workspace units.

getCheck

public

getCheck() returns Array

Get a connection's compatibility.

Inherited from
Blockly.Connection#getCheck
Returns

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

getOffsetInBlock

package

getOffsetInBlock() returns Blockly.utils.Coordinate

Get the offset of this connection relative to the top left of its block.

Returns

non-null Blockly.utils.Coordinate The offset of the connection.

getParentInput

package

getParentInput() returns Blockly.Input

Get the parent input of a connection.

Inherited from
Blockly.Connection#getParentInput
Returns

The input that the connection belongs to or null if no parent exists.

getShadowDom

getShadowDom() returns Element

Return a connection's shadow block.

Inherited from
Blockly.Connection#getShadowDom
Returns

Shadow DOM representation of a block or null.

getSourceBlock

getSourceBlock() returns Blockly.BlockSvg

Get the source block for this connection.

Inherited from
Blockly.RenderedConnection#getSourceBlock
Implements
Blockly.IASTNodeLocationWithBlock#getSourceBlock
Returns

The source block.

highlight

highlight()

Add highlighting around this connection.

isConnected

isConnected() returns boolean

Is the connection connected?

Inherited from
Blockly.Connection#isConnected
Returns

True if connection is connected to another connection.

isConnectionAllowed

isConnectionAllowed(candidate, maxRadius) 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.

maxRadius

Optional

number

The maximum radius allowed for connections, in workspace units.

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)?

Inherited from
Blockly.Connection#isSuperior
Returns

True if connection faces down or right.

moveBy

moveBy(dx, dy)

Change the connection's coordinates.

Parameter

dx

number

Change to x coordinate, in workspace units.

dy

number

Change to y coordinate, in workspace units.

moveTo

moveTo(x, y)

Change the connection's coordinates.

Parameter

x

number

New absolute x coordinate, in workspace coordinates.

y

number

New absolute y coordinate, in workspace coordinates.

moveToOffset

moveToOffset(blockTL)

Move this connection to the location given by its offset within the block and the location of the block's top left corner.

Parameter

blockTL

Blockly.utils.Coordinate

The location of the top left corner of the block, in workspace coordinates.

Value must not be null.

neighbours

package

neighbours(maxLimit) returns Array of non-null Blockly.Connection

Find all nearby compatible connections to this connection. Type checking does not apply, since this function is used for bumping.

Parameter

maxLimit

number

The maximum radius to another connection, in workspace units.

Returns

non-null Array of non-null Blockly.Connection List of connections.

onCheckChanged_

protected

onCheckChanged_()

Function to be called when this connection's compatible types have changed.

onFailedConnect

package

onFailedConnect(otherConnection)

Behavior after a connection attempt fails.

Parameter

otherConnection

Blockly.Connection

Connection that this connection failed to connect to.

Value must not be null.

setCheck

setCheck(check) returns Blockly.Connection

Change a connection's compatibility.

Parameter

check

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

Value may be null.

Inherited from
Blockly.Connection#setCheck
Returns

The connection being modified (to allow chaining).

setOffsetInBlock

setOffsetInBlock(x, y)

Set the offset of this connection relative to the top left of its block.

Parameter

x

number

The new relative x, in workspace units.

y

number

The new relative y, in workspace units.

setShadowDom

setShadowDom(shadow)

Change a connection's shadow block.

Parameter

shadow

DOM representation of a block or null.

Inherited from
Blockly.Connection#setShadowDom

setTracking

package

setTracking(doTracking)

Set whether this connections is tracked in the database or not.

Parameter

doTracking

boolean

If true, start tracking. If false, stop tracking.

startTrackingAll

startTrackingAll() returns Array of non-null Blockly.Block

Start tracking this connection, as well as all down-stream connections on any block attached to this connection. This happens when a block is expanded.

Returns

non-null Array of non-null Blockly.Block List of blocks to render.

stopTrackingAll

package

stopTrackingAll()

Stop tracking this connection, as well as all down-stream connections on any block attached to this connection. This happens when a block is collapsed.

Also closes down-stream icons/bubbles.

targetBlock

targetBlock() returns Blockly.BlockSvg

Returns the block that this connection connects to.

Inherited from
Blockly.RenderedConnection#targetBlock
Returns

The connected block or null if none is connected.

tighten

package

tighten()

Move the blocks on either side of this connection right next to each other.

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.

Inherited from
Blockly.Connection#toString
Returns

The description.

unhighlight

unhighlight()

Remove the highlighting around this connection.