Blockly. RenderedConnection
Constructor
RenderedConnection
new RenderedConnection(source, type)
Class for a connection between blocks that may be rendered on screen.
Parameter |
|
---|---|
source |
The block establishing this connection. Value must not be null. |
type |
number The type of the connection. |
- Extends
- Blockly.Connection
Enumeration
TrackedState
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
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
unknown
Has this connection been disposed of?
- Inherited from
- Blockly.Connection#disposed
sourceBlock_
non-null Blockly.BlockSvg
targetConnection
Connection this connection connects to. Null if not connected.
type
unknown
- Inherited from
- Blockly.Connection#type
x
unknown
Horizontal location of this connection.
- Inherited from
- Blockly.Connection#x
y
unknown
Vertical location of this connection.
- Inherited from
- Blockly.Connection#y
Methods
bumpAwayFrom
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 |
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
- Deprecated
- July 2020. Will be deleted July 2021. Use the workspace's connectionChecker instead.
- Returns
-
Blockly.Connection.CAN_CONNECT if the connection is legal, an error code otherwise.
checkConnection
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
- Deprecated
- July 2020. Will be deleted July 2021. Use the workspace's connectionChecker instead.
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
- Deprecated
- July 2020. Will be deleted July 2021. Use the workspace's connectionChecker instead.
- 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 |
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_
connect_(childConnection)
Connect two connections together. This is the connection on the superior block. Rerender blocks as needed.
Parameter |
|
---|---|
childConnection |
Connection on inferior block. Value must not be null. |
disconnect
disconnect()
Disconnect this connection.
- Inherited from
- Blockly.Connection#disconnect
dispose
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 |
The other connection to measure the distance to. Value must not be null. |
- Returns
-
number
The distance between connections, in workspace units.
getCheck
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.
getConnectionChecker
getConnectionChecker() returns Blockly.IConnectionChecker
Get the workspace's connection type checker object.
- Inherited from
- Blockly.Connection#getConnectionChecker
- Returns
-
The connection type checker for the source block's workspace.
getOffsetInBlock
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
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
Returns the xml representation of the 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 |
A nearby connection to check. Value must not be null. |
maxRadius |
Optional number The maximum radius allowed for connections, in workspace units. |
- Deprecated
- July 2020
- 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 |
The location of the top left corner of the block, in workspace coordinates. Value must not be null. |
neighbours
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_
onCheckChanged_()
Function to be called when this connection's compatible types have changed.
onFailedConnect
onFailedConnect(otherConnection)
Behavior after a connection attempt fails.
Parameter |
|
---|---|
otherConnection |
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)
Changes the connection's shadow block.
Parameter |
|
---|---|
shadow |
DOM representation of a block or null. |
- Inherited from
- Blockly.Connection#setShadowDom
setTracking
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
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
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.