Class: RenderedConnection
Defined in: packages/blockly/core/rendered_connection.ts:42
Class for a connection between blocks that may be rendered on screen.
Extends
Implements
Properties index
| Property | Description |
|---|---|
| CAN_CONNECT | Constants for checking whether two connections are compatible. |
| REASON_SELF_CONNECTION | - |
| REASON_WRONG_TYPE | - |
| REASON_TARGET_NULL | - |
| REASON_CHECKS_FAILED | - |
| REASON_DIFFERENT_WORKSPACES | - |
| REASON_SHADOW_PARENT | - |
| REASON_DRAG_CHECKS_FAILED | - |
| REASON_PREVIOUS_AND_OUTPUT | - |
| id | The unique ID of this connection. |
| type | The type of the connection. |
| sourceBlock_ | - |
| targetConnection | Connection this connection connects to. Null if not connected. |
Methods index
| Method | Description |
|---|---|
| isSuperior | Does the connection belong to a superior block (higher in the source stack)? |
| isConnected | Is the connection connected? |
| connect | Connect this connection to another connection. |
| disconnect | Disconnect this connection. |
| getParentAndChildConnections | Returns the parent connection (superior) and child connection (inferior) given this connection and the connection it is connected to. |
| reconnect | Reconnects this connection to the input with the given name on the given block. If there is already a connection connected to that input, that connection is disconnected. |
| getCheck | Get a connection's compatibility. |
| setShadowDom | Changes the connection's shadow block. |
| getShadowDom | Returns the xml representation of the connection's shadow block. |
| setShadowState | Changes the connection's shadow block. |
| getShadowState | Returns the serialized object representation of the connection's shadow block. |
| toString | This method returns a string describing this Connection in developer terms (English only). Intended to on be used in console logs and errors. |
| getConnectionForOrphanedConnection | Returns the connection (starting at the startBlock) which will accept the given connection. This includes compatible connection types and connection checks. |
| getSourceBlock | Get the source block for this connection. |
| targetBlock | Returns the block that this connection connects to. |
| distanceFrom | Returns the distance between this connection and another connection in workspace units. |
| moveTo | Change the connection's coordinates. |
| moveBy | Change the connection's coordinates. |
| moveToOffset | Move this connection to the location given by its offset within the block and the location of the block's top left corner. |
| setOffsetInBlock | Set the offset of this connection relative to the top left of its block. |
| getOffsetInBlock | Get the offset of this connection relative to the top left of its block. |
| closest | Find the closest compatible connection to this connection. All parameters are in workspace units. |
| setAriaRole | Sets the aria role and role description for this connection. |
| highlight | Add highlighting around this connection. |
| unhighlight | Remove the highlighting around this connection. |
| isHighlighted | Returns true if this connection is highlighted, false otherwise. |
| startTrackingAll | 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. |
| disconnectInternal | Disconnect two blocks that are connected by this connection. |
| respawnShadow_ | Respawn the shadow block if there was one connected to the this connection. Render/rerender blocks as needed. |
| connect_ | Connect two connections together. This is the connection on the superior block. Rerender blocks as needed. |
| onCheckChanged_ | Function to be called when this connection's compatible types have changed. |
| setCheck | Change a connection's compatibility. Rerender blocks as needed. |
| showContextMenu | Handles showing the context menu when it is opened on a connection. Note that typically the context menu can't be opened with the mouse on a connection, because you can't select a connection. But keyboard users may open the context menu with a keyboard shortcut. |
| getFocusableElement | See IFocusableNode.getFocusableElement. |
| getFocusableTree | See IFocusableNode.getFocusableTree. |
| onNodeFocus | See IFocusableNode.onNodeFocus. |
| onNodeBlur | See IFocusableNode.onNodeBlur. |
| canBeFocused | See IFocusableNode.canBeFocused. |
Constructors
Constructor
new RenderedConnection(source, type): RenderedConnection;
Defined in: packages/blockly/core/rendered_connection.ts:62
Parameters
| Parameter | Type | Description |
|---|---|---|
source | BlockSvg | The block establishing this connection. |
type | number | The type of the connection. |
Returns
RenderedConnection
Overrides
Properties
CAN_CONNECT
static CAN_CONNECT: number = 0;
Defined in: packages/blockly/core/connection.ts:30
Constants for checking whether two connections are compatible.
Inherited from
REASON_SELF_CONNECTION
static REASON_SELF_CONNECTION: number = 1;
Defined in: packages/blockly/core/connection.ts:31
Inherited from
Connection.REASON_SELF_CONNECTION
REASON_WRONG_TYPE
static REASON_WRONG_TYPE: number = 2;
Defined in: packages/blockly/core/connection.ts:32
Inherited from
REASON_TARGET_NULL
static REASON_TARGET_NULL: number = 3;
Defined in: packages/blockly/core/connection.ts:33
Inherited from
REASON_CHECKS_FAILED
static REASON_CHECKS_FAILED: number = 4;
Defined in: packages/blockly/core/connection.ts:34
Inherited from
Connection.REASON_CHECKS_FAILED
REASON_DIFFERENT_WORKSPACES
static REASON_DIFFERENT_WORKSPACES: number = 5;
Defined in: packages/blockly/core/connection.ts:35
Inherited from
Connection.REASON_DIFFERENT_WORKSPACES
REASON_SHADOW_PARENT
static REASON_SHADOW_PARENT: number = 6;
Defined in: packages/blockly/core/connection.ts:36
Inherited from
Connection.REASON_SHADOW_PARENT
REASON_DRAG_CHECKS_FAILED
static REASON_DRAG_CHECKS_FAILED: number = 7;
Defined in: packages/blockly/core/connection.ts:37
Inherited from
Connection.REASON_DRAG_CHECKS_FAILED
REASON_PREVIOUS_AND_OUTPUT
static REASON_PREVIOUS_AND_OUTPUT: number = 8;
Defined in: packages/blockly/core/connection.ts:38
Inherited from
Connection.REASON_PREVIOUS_AND_OUTPUT
id
id: string;
Defined in: packages/blockly/core/connection.ts:59
The unique ID of this connection.
Inherited from
type
type: number;
Defined in: packages/blockly/core/connection.ts:83
The type of the connection.
Inherited from
sourceBlock_
sourceBlock_: BlockSvg;
Defined in: packages/blockly/core/rendered_connection.ts:47
Overrides
targetConnection
targetConnection: RenderedConnection | null = null;
Defined in: packages/blockly/core/rendered_connection.ts:56
Connection this connection connects to. Null if not connected.
Overrides
Methods
isSuperior()
isSuperior(): boolean;
Defined in: packages/blockly/core/connection.ts:197
Does the connection belong to a superior block (higher in the source stack)?
Returns
boolean
True if connection faces down or right.
Inherited from
isConnected()
isConnected(): boolean;
Defined in: packages/blockly/core/connection.ts:209
Is the connection connected?
Returns
boolean
True if connection is connected to another connection.
Inherited from
connect()
connect(otherConnection): boolean;
Defined in: packages/blockly/core/connection.ts:240
Connect this connection to another connection.
Parameters
| Parameter | Type | Description |
|---|---|---|
otherConnection | Connection | Connection to connect to. |
Returns
boolean
Whether the blocks are now connected or not.
Inherited from
disconnect()
disconnect(): void;
Defined in: packages/blockly/core/connection.ts:269
Disconnect this connection.
Returns
void
Inherited from
getParentAndChildConnections()
protected getParentAndChildConnections(): object;
Defined in: packages/blockly/core/connection.ts:326
Returns the parent connection (superior) and child connection (inferior) given this connection and the connection it is connected to.
Returns
object
The parent connection and child connection, given this connection and the connection it is connected to.
parentConnection?
optional parentConnection?: Connection;
childConnection?
optional childConnection?: Connection;
Inherited from
Connection.getParentAndChildConnections
reconnect()
reconnect(block, inputName): boolean;
Defined in: packages/blockly/core/connection.ts:360
Reconnects this connection to the input with the given name on the given block. If there is already a connection connected to that input, that connection is disconnected.
Parameters
| Parameter | Type | Description |
|---|---|---|
block | Block | The block to connect this connection to. |
inputName | string | The name of the input to connect this connection to. |
Returns
boolean
True if this connection was able to connect, false otherwise.
Inherited from
getCheck()
getCheck(): string[] | null;
Defined in: packages/blockly/core/connection.ts:438
Get a connection's compatibility.
Returns
string[] | null
List of compatible value types. Null if all types are compatible.
Inherited from
setShadowDom()
setShadowDom(shadowDom): void;
Defined in: packages/blockly/core/connection.ts:447
Changes the connection's shadow block.
Parameters
| Parameter | Type | Description |
|---|---|---|
shadowDom | Element | null | DOM representation of a block or null. |
Returns
void
Inherited from
getShadowDom()
getShadowDom(returnCurrent?): Element | null;
Defined in: packages/blockly/core/connection.ts:460
Returns the xml representation of the connection's shadow block.
Parameters
| Parameter | Type | Description |
|---|---|---|
returnCurrent? | boolean | If true, and the shadow block is currently attached to this connection, this serializes the state of that block and returns it (so that field values are correct). Otherwise the saved shadowDom is just returned. |
Returns
Element | null
Shadow DOM representation of a block or null.
Inherited from
setShadowState()
setShadowState(shadowState): void;
Defined in: packages/blockly/core/connection.ts:471
Changes the connection's shadow block.
Parameters
| Parameter | Type | Description |
|---|---|---|
shadowState | | State | null | An state represetation of the block or null. |
Returns
void
Inherited from
getShadowState()
getShadowState(returnCurrent?):
| State
| null;
Defined in: packages/blockly/core/connection.ts:485
Returns the serialized object representation of the connection's shadow block.
Parameters
| Parameter | Type | Description |
|---|---|---|
returnCurrent? | boolean | If true, and the shadow block is currently attached to this connection, this serializes the state of that block and returns it (so that field values are correct). Otherwise the saved state is just returned. |
Returns
| State
| null
Serialized object representation of the block, or null.
Inherited from
toString()
toString(): string;
Defined in: packages/blockly/core/connection.ts:534
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.
Inherited from
getConnectionForOrphanedConnection()
static getConnectionForOrphanedConnection(startBlock, orphanConnection): Connection | null;
Defined in: packages/blockly/core/connection.ts:717
Returns the connection (starting at the startBlock) which will accept the given connection. This includes compatible connection types and connection checks.
Parameters
| Parameter | Type | Description |
|---|---|---|
startBlock | Block | The block on which to start the search. |
orphanConnection | Connection | The connection that is looking for a home. |
Returns
Connection | null
The suitable connection point on the chain of blocks, or null.
Inherited from
Connection.getConnectionForOrphanedConnection
getSourceBlock()
getSourceBlock(): BlockSvg;
Defined in: packages/blockly/core/rendered_connection.ts:104
Get the source block for this connection.
Returns
The source block.
Overrides
targetBlock()
targetBlock(): BlockSvg | null;
Defined in: packages/blockly/core/rendered_connection.ts:113
Returns the block that this connection connects to.
Returns
BlockSvg | null
The connected block or null if none is connected.
Overrides
distanceFrom()
distanceFrom(otherConnection): number;
Defined in: packages/blockly/core/rendered_connection.ts:124
Returns the distance between this connection and another connection in workspace units.
Parameters
| Parameter | Type | Description |
|---|---|---|
otherConnection | Connection | The other connection to measure the distance to. |
Returns
number
The distance between connections, in workspace units.
moveTo()
moveTo(x, y): boolean;
Defined in: packages/blockly/core/rendered_connection.ts:220
Change the connection's coordinates.
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | New absolute x coordinate, in workspace coordinates. |
y | number | New absolute y coordinate, in workspace coordinates. |
Returns
boolean
True if the position of the connection in the connection db was updated.
moveBy()
moveBy(dx, dy): boolean;
Defined in: packages/blockly/core/rendered_connection.ts:250
Change the connection's coordinates.
Parameters
| Parameter | Type | Description |
|---|---|---|
dx | number | Change to x coordinate, in workspace units. |
dy | number | Change to y coordinate, in workspace units. |
Returns
boolean
True if the position of the connection in the connection db was updated.
moveToOffset()
moveToOffset(blockTL): boolean;
Defined in: packages/blockly/core/rendered_connection.ts:263
Move this connection to the location given by its offset within the block and the location of the block's top left corner.
Parameters
| Parameter | Type | Description |
|---|---|---|
blockTL | Coordinate | The location of the top left corner of the block, in workspace coordinates. |
Returns
boolean
True if the position of the connection in the connection db was updated.
setOffsetInBlock()
setOffsetInBlock(x, y): void;
Defined in: packages/blockly/core/rendered_connection.ts:276
Set the offset of this connection relative to the top left of its block.
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | The new relative x, in workspace units. |
y | number | The new relative y, in workspace units. |
Returns
void
getOffsetInBlock()
getOffsetInBlock(): Coordinate;
Defined in: packages/blockly/core/rendered_connection.ts:286
Get the offset of this connection relative to the top left of its block.
Returns
The offset of the connection.
closest()
closest(maxLimit, dxy): object;
Defined in: packages/blockly/core/rendered_connection.ts:326
Find the closest compatible connection to this connection. All parameters are in workspace units.
Parameters
| Parameter | Type | Description |
|---|---|---|
maxLimit | number | The maximum radius to another connection. |
dxy | Coordinate | Offset between this connection's location in the database and the current location (as a result of dragging). |
Returns
object
Contains two properties: 'connection' which is either another connection or null, and 'radius' which is the distance.
connection
connection: RenderedConnection | null;
radius
radius: number;
setAriaRole()
setAriaRole(highlightSvg): void;
Defined in: packages/blockly/core/rendered_connection.ts:338
Sets the aria role and role description for this connection.
Parameters
| Parameter | Type | Description |
|---|---|---|
highlightSvg | SVGElement | The focusable element for this connection. |
Returns
void
highlight()
highlight(): void;
Defined in: packages/blockly/core/rendered_connection.ts:395
Add highlighting around this connection.
Returns
void
unhighlight()
unhighlight(): void;
Defined in: packages/blockly/core/rendered_connection.ts:419
Remove the highlighting around this connection.
Returns
void
isHighlighted()
isHighlighted(): boolean;
Defined in: packages/blockly/core/rendered_connection.ts:430
Returns true if this connection is highlighted, false otherwise.
Returns
boolean
startTrackingAll()
startTrackingAll(): BlockSvg[];
Defined in: packages/blockly/core/rendered_connection.ts:499
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
BlockSvg[]
List of blocks to render.
disconnectInternal()
disconnectInternal(setParent?): void;
Defined in: packages/blockly/core/rendered_connection.ts:572
Disconnect two blocks that are connected by this connection.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
setParent | boolean | true | Whether to set the parent of the disconnected block or not, defaults to true. If you do not set the parent, ensure that a subsequent action does, otherwise the view and model will be out of sync. |
Returns
void
Overrides
respawnShadow_()
protected respawnShadow_(): void;
Defined in: packages/blockly/core/rendered_connection.ts:596
Respawn the shadow block if there was one connected to the this connection. Render/rerender blocks as needed.
Returns
void
Overrides
connect_()
protected connect_(childConnection): void;
Defined in: packages/blockly/core/rendered_connection.ts:625
Connect two connections together. This is the connection on the superior block. Rerender blocks as needed.
Parameters
| Parameter | Type | Description |
|---|---|---|
childConnection | Connection | Connection on inferior block. |
Returns
void
Overrides
onCheckChanged_()
protected onCheckChanged_(): void;
Defined in: packages/blockly/core/rendered_connection.ts:648
Function to be called when this connection's compatible types have changed.
Returns
void
Overrides
setCheck()
setCheck(check): RenderedConnection;
Defined in: packages/blockly/core/rendered_connection.ts:672
Change a connection's compatibility. Rerender blocks as needed.
Parameters
| Parameter | Type | Description |
|---|---|---|
check | string | string[] | null | Compatible value type or list of value types. Null if all types are compatible. |
Returns
RenderedConnection
The connection being modified (to allow chaining).
Overrides
showContextMenu()
showContextMenu(e): void;
Defined in: packages/blockly/core/rendered_connection.ts:686
Handles showing the context menu when it is opened on a connection. Note that typically the context menu can't be opened with the mouse on a connection, because you can't select a connection. But keyboard users may open the context menu with a keyboard shortcut.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | Event | Event that triggered the opening of the context menu. |
Returns
void
Implementation of
getFocusableElement()
getFocusableElement(): HTMLElement | SVGElement;
Defined in: packages/blockly/core/rendered_connection.ts:713
See IFocusableNode.getFocusableElement.
Returns
HTMLElement | SVGElement
Implementation of
IFocusableNode.getFocusableElement
getFocusableTree()
getFocusableTree(): IFocusableTree;
Defined in: packages/blockly/core/rendered_connection.ts:720
See IFocusableNode.getFocusableTree.
Returns
Implementation of
IFocusableNode.getFocusableTree
onNodeFocus()
onNodeFocus(): void;
Defined in: packages/blockly/core/rendered_connection.ts:725
See IFocusableNode.onNodeFocus.
Returns
void
Implementation of
onNodeBlur()
onNodeBlur(): void;
Defined in: packages/blockly/core/rendered_connection.ts:737
See IFocusableNode.onNodeBlur.
Returns
void
Implementation of
canBeFocused()
canBeFocused(): boolean;
Defined in: packages/blockly/core/rendered_connection.ts:742
See IFocusableNode.canBeFocused.
Returns
boolean