GraphEdit

Inherits: Control < CanvasItem < Node < Object

Category: Core

Brief Description

GraphEdit is an area capable of showing various GraphNodes. It manages connection events between them.

Member Functions

void add_valid_connection_type ( int from_type, int to_type )
void add_valid_left_disconnect_type ( int type )
void add_valid_right_disconnect_type ( int type )
void clear_connections ( )
int connect_node ( String from, int from_port, String to, int to_port )
void disconnect_node ( String from, int from_port, String to, int to_port )
Array get_connection_list ( ) const
bool is_node_connected ( String from, int from_port, String to, int to_port )
bool is_valid_connection_type ( int from_type, int to_type ) const
void remove_valid_connection_type ( int from_type, int to_type )
void remove_valid_left_disconnect_type ( int type )
void remove_valid_right_disconnect_type ( int type )
void set_selected ( Node node )

Signals

  • _begin_node_move ( )

Signal sent at the beginning of a GraphNode movement.

  • _end_node_move ( )

Signal sent at the end of a GraphNode movement.

Signal sent to the GraphEdit when the connection between ‘from_slot’ slot of ‘from’ GraphNode and ‘to_slot’ slot of ‘to’ GraphNode is attempted to be created.

  • delete_nodes_request ( )

Signal sent when a GraphNode is attempted to be removed from the GraphEdit.

Signal sent to the GraphEdit when the connection between ‘from_slot’ slot of ‘from’ GraphNode and ‘to_slot’ slot of ‘to’ GraphNode is attempted to be removed.

  • duplicate_nodes_request ( )

Signal sent when a GraphNode is attempted to be duplicated in the GraphEdit.

  • node_selected ( Object node )

Emitted when a GraphNode is selected.

  • popup_request ( Vector2 p_position )

Signal sent when a popup is requested. Happens on right-clicking in the GraphEdit. ‘p_position’ is the position of the mouse pointer when the signal is sent.

  • scroll_offset_changed ( Vector2 ofs )

Member Variables

  • bool right_disconnects - If true, enables disconnection of existing connections in the GraphEdit by dragging the right end.
  • Vector2 scroll_offset - The scroll offset.
  • int snap_distance - The snapping distance in pixels.
  • bool use_snap - If true, enables snapping.
  • float zoom - The current zoom value.

Description

GraphEdit manages the showing of GraphNodes it contains, as well as connections and disconnections between them. Signals are sent for each of these two events. Disconnection between GraphNodes slots is disabled by default.

It is greatly advised to enable low processor usage mode (see OS.set_low_processor_usage_mode) when using GraphEdits.

Member Function Description

  • void add_valid_connection_type ( int from_type, int to_type )

Makes possible the connection between two different slot types. The type is defined with the GraphNode.set_slot method.

  • void add_valid_left_disconnect_type ( int type )

Makes possible to disconnect nodes when dragging from the slot at the left if it has the specified type.

  • void add_valid_right_disconnect_type ( int type )

Makes possible to disconnect nodes when dragging from the slot at the right if it has the specified type.

  • void clear_connections ( )

Remove all connections between nodes.

Create a connection between ‘from_port’ slot of ‘from’ GraphNode and ‘to_port’ slot of ‘to’ GraphNode. If the connection already exists, no connection is created.

Remove the connection between ‘from_port’ slot of ‘from’ GraphNode and ‘to_port’ slot of ‘to’ GraphNode, if connection exists.

  • Array get_connection_list ( ) const

Return an Array containing the list of connections. A connection consists in a structure of the form {from_slot: 0, from: “GraphNode name 0”, to_slot: 1, to: “GraphNode name 1” }

Return true if the ‘from_port’ slot of ‘from’ GraphNode is connected to the ‘to_port’ slot of ‘to’ GraphNode.

  • bool is_valid_connection_type ( int from_type, int to_type ) const

Returns whether it’s possible to connect slots of the specified types.

  • void remove_valid_connection_type ( int from_type, int to_type )

Makes it not possible to connect between two different slot types. The type is defined with the GraphNode.set_slot method.

  • void remove_valid_left_disconnect_type ( int type )

Removes the possibility to disconnect nodes when dragging from the slot at the left if it has the specified type.

  • void remove_valid_right_disconnect_type ( int type )

Removes the possibility to disconnect nodes when dragging from the slot at the right if it has the specified type.

  • void set_selected ( Node node )

Sets the specified node as the one selected.