GraphEdit

Inherits: Control < CanvasItem < Node < Object

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

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 GraphNode slots is disabled by default.

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

Properties

FocusModefocus_modeO: 2
boolrect_clip_contentO: true
boolright_disconnectsfalse
Vector2scroll_offsetVector2( 0, 0 )
intsnap_distance20
booluse_snaptrue
floatzoom1.0

Methods

voidadd_valid_connection_type ( int from_type, int to_type )
voidadd_valid_left_disconnect_type ( int type )
voidadd_valid_right_disconnect_type ( int type )
voidclear_connections ( )
Errorconnect_node ( String from, int from_port, String to, int to_port )
voiddisconnect_node ( String from, int from_port, String to, int to_port )
Arrayget_connection_list ( ) const
HBoxContainerget_zoom_hbox ( )
boolis_node_connected ( String from, int from_port, String to, int to_port )
boolis_valid_connection_type ( int from_type, int to_type ) const
voidremove_valid_connection_type ( int from_type, int to_type )
voidremove_valid_left_disconnect_type ( int type )
voidremove_valid_right_disconnect_type ( int type )
voidset_connection_activity ( String from, int from_port, String to, int to_port, float amount )
voidset_selected ( Node node )

Theme Properties

ColoractivityColor( 1, 1, 1, 1 )
intbezier_len_neg160
intbezier_len_pos80
StyleBoxbg 
Colorgrid_majorColor( 1, 1, 1, 0.2 )
Colorgrid_minorColor( 1, 1, 1, 0.05 )
Textureminus 
Texturemore 
intport_grab_distance_horizontal48
intport_grab_distance_vertical6
Texturereset 
Colorselection_fillColor( 1, 1, 1, 0.3 )
Colorselection_strokeColor( 1, 1, 1, 0.8 )
Texturesnap 

Signals

  • _begin_node_move ( )

Emitted at the beginning of a GraphNode movement.


  • _end_node_move ( )

Emitted at the end of a GraphNode movement.


Emitted when user dragging connection from input port into empty space of the graph.


Emitted to the GraphEdit when the connection between the from_slot slot of the from GraphNode and the to_slot slot of the to GraphNode is attempted to be created.


Emitted when user dragging connection from output port into empty space of the graph.


  • copy_nodes_request ( )

Emitted when the user presses Ctrl + C.


  • delete_nodes_request ( )

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


Emitted 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 ( )

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


  • node_selected ( Node node )

Emitted when a GraphNode is selected.


  • paste_nodes_request ( )

Emitted when the user presses Ctrl + V.


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


  • scroll_offset_changed ( Vector2 ofs )

Emitted when the scroll offset is changed by the user. It will not be emitted when changed in code.

Property Descriptions

  • bool right_disconnects
Defaultfalse
Setterset_right_disconnects(value)
Getteris_right_disconnects_enabled()

If true, enables disconnection of existing connections in the GraphEdit by dragging the right end.


DefaultVector2( 0, 0 )
Setterset_scroll_ofs(value)
Getterget_scroll_ofs()

The scroll offset.


  • int snap_distance
Default20
Setterset_snap(value)
Getterget_snap()

The snapping distance in pixels.


Defaulttrue
Setterset_use_snap(value)
Getteris_using_snap()

If true, enables snapping.


Default1.0
Setterset_zoom(value)
Getterget_zoom()

The current zoom value.

Method Descriptions

  • 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 ( )

Removes all connections between nodes.


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


Removes the connection between the from_port slot of the from GraphNode and the to_port slot of the to GraphNode. If the connection does not exist, no connection is removed.


  • Array get_connection_list ( ) const

Returns an Array containing the list of connections. A connection consists in a structure of the form { from_port: 0, from: "GraphNode name 0", to_port: 1, to: "GraphNode name 1" }.


Gets the HBoxContainer that contains the zooming and grid snap controls in the top left of the graph.

Warning: The intended usage of this function is to allow you to reposition or add your own custom controls to the container. This is an internal control and as such should not be freed. If you wish to hide this or any of it’s children use their CanvasItem.visible property instead.


Returns true if the from_port slot of the from GraphNode is connected to the to_port slot of the 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.


Sets the coloration of the connection between from’s from_port and to’s to_port with the color provided in the activity theme property.


  • void set_selected ( Node node )

Sets the specified node as the one selected.

Doc ID missing

Disclaimer: This page has been automaticaly and directly extracted from the official Godot Docs website, the 1970-01-01 at 00:00:00. It’s the English Stable version because it’s what most Godot users should use. The Copyright owners are Juan Linietsky, Ariel Manzur and the Godot community. CC-BY 3.0. Thanks for your patience and generosity.