GraphEdit

package
v0.0.0-...-9b8b246 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

GraphEdit provides tools for creation, manipulation, and display of various graphs. Its main purpose in the engine is to power the visual programming systems, such as visual shaders, but it is also available for use in user projects.

GraphEdit by itself is only an empty container, representing an infinite grid where GraphNodes can be placed. Each GraphNode represents a node in the graph, a single unit of data in the connected scheme. GraphEdit, in turn, helps to control various interactions with nodes and between nodes. When the user attempts to connect, disconnect, or delete a GraphNode, a signal is emitted in the GraphEdit, but no action is taken by default. It is the responsibility of the programmer utilizing this control to implement the necessary logic to determine how each request should be handled.

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

Note: Keep in mind that Node.GetChildren will also return the connection layer node named _connection_layer due to technical limitations. This behavior may change in future releases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsGraphEdit() Instance
}

type Connection

type Connection struct {
	FromNode  string `gd:"from_node"`
	FromPort  int    `gd:"from_port"`
	ToNode    string `gd:"to_node"`
	ToPort    int    `gd:"to_port"`
	KeepAlive bool   `gd:"keep_alive"`
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsControl

func (self *Extension[T]) AsControl() Control.Instance

func (*Extension[T]) AsGraphEdit

func (self *Extension[T]) AsGraphEdit() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type GridPattern

type GridPattern int //gd:GraphEdit.GridPattern
const (
	// Draw the grid using solid lines.
	GridPatternLines GridPattern = 0
	// Draw the grid using dots.
	GridPatternDots GridPattern = 1
)

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.GraphEdit

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddValidConnectionType

func (self Instance) AddValidConnectionType(from_type int, to_type int)

Allows the connection between two different port types. The port type is defined individually for the left and the right port of each slot with the GraphNode.SetSlot method.

See also IsValidConnectionType and RemoveValidConnectionType.

func (Instance) AddValidLeftDisconnectType

func (self Instance) AddValidLeftDisconnectType(atype int)

Allows to disconnect nodes when dragging from the left port of the GraphNode's slot if it has the specified type. See also RemoveValidLeftDisconnectType.

func (Instance) AddValidRightDisconnectType

func (self Instance) AddValidRightDisconnectType(atype int)

Allows to disconnect nodes when dragging from the right port of the GraphNode's slot if it has the specified type. See also RemoveValidRightDisconnectType.

func (Instance) ArrangeNodes

func (self Instance) ArrangeNodes()

Rearranges selected nodes in a layout with minimum crossings between connections and uniform horizontal and vertical gap between nodes.

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsControl

func (self Instance) AsControl() Control.Instance

func (Instance) AsGraphEdit

func (self Instance) AsGraphEdit() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AttachGraphElementToFrame

func (self Instance) AttachGraphElementToFrame(element string, frame_ string)

Attaches the 'element' GraphElement to the 'frame' GraphFrame.

func (Instance) ClearConnections

func (self Instance) ClearConnections()

Removes all connections between nodes.

func (Instance) ConnectNode

func (self Instance) ConnectNode(from_node string, from_port int, to_node string, to_port int) error

Create a connection between the 'from_port' of the 'from_node' GraphNode and the 'to_port' of the 'to_node' GraphNode. If the connection already exists, no connection is created.

Connections with 'keep_alive' set to false may be deleted automatically if invalid during a redraw.

func (Instance) ConnectionLinesAntialiased

func (self Instance) ConnectionLinesAntialiased() bool

If true, the lines between nodes will use antialiasing.

func (Instance) ConnectionLinesCurvature

func (self Instance) ConnectionLinesCurvature() Float.X

The curvature of the lines between the nodes. 0 results in straight lines.

func (Instance) ConnectionLinesThickness

func (self Instance) ConnectionLinesThickness() Float.X

The thickness of the lines between the nodes.

func (Instance) Connections

func (self Instance) Connections() []Connection

The connections between GraphNodes.

A connection is represented as a data structure in the form of:

Connections with keep_alive set to false may be deleted automatically if invalid during a redraw.

func (Instance) DetachGraphElementFromFrame

func (self Instance) DetachGraphElementFromFrame(element string)

Detaches the 'element' GraphElement from the GraphFrame it is currently attached to.

func (Instance) DisconnectNode

func (self Instance) DisconnectNode(from_node string, from_port int, to_node string, to_port int)

Removes the connection between the 'from_port' of the 'from_node' GraphNode and the 'to_port' of the 'to_node' GraphNode. If the connection does not exist, no connection is removed.

func (Instance) ForceConnectionDragEnd

func (self Instance) ForceConnectionDragEnd()

Ends the creation of the current connection. In other words, if you are dragging a connection you can use this method to abort the process and remove the line that followed your cursor.

This is best used together with OnConnectionDragStarted and OnConnectionDragEnded to add custom behavior like node addition through shortcuts.

Note: This method suppresses any other connection request signals apart from OnConnectionDragEnded.

func (Instance) GetAttachedNodesOfFrame

func (self Instance) GetAttachedNodesOfFrame(frame_ string) []string

Returns an array of node names that are attached to the GraphFrame with the given name.

func (Instance) GetClosestConnectionAtPoint

func (self Instance) GetClosestConnectionAtPoint(point Vector2.XY) Connection

Returns the closest connection to the given point in screen space. If no connection is found within 'max_distance' pixels, an empty data structure is returned.

A connection is represented as a data structure in the form of:

type Connection struct {
	FromNode  string `gd:"from_node"`
	FromPort  int    `gd:"from_port"`
	ToNode    string `gd:"to_node"`
	ToPort    int    `gd:"to_port"`
	KeepAlive bool   `gd:"keep_alive"`
}

For example, getting a connection at a given mouse position can be achieved like this:

func (Instance) GetConnectionCount

func (self Instance) GetConnectionCount(from_node string, from_port int) int

Returns the number of connections from 'from_port' of 'from_node'.

func (Instance) GetConnectionLine

func (self Instance) GetConnectionLine(from_node Vector2.XY, to_node Vector2.XY) []Vector2.XY

Returns the points which would make up a connection between 'from_node' and 'to_node'.

func (Instance) GetConnectionListFromNode

func (self Instance) GetConnectionListFromNode(node string) [][]Connection

Returns an slice containing a list of all connections for 'node'.

A connection is represented as a data structure in the form of:

type Connection struct {
	FromNode  string `json:"from_node"`
	FromPort  int    `json:"from_port"`
	ToNode    string `json:"to_node"`
	ToPort    int    `json:"to_port"`
	KeepAlive bool   `json:"keep_alive"`
}

Example: Get all connections on a specific port:

func (Instance) GetConnectionsIntersectingWithRect

func (self Instance) GetConnectionsIntersectingWithRect(rect Rect2.PositionSize) []Connection

Returns an slice containing the list of connections that intersect with the given Rect2.PositionSize.

A connection is represented as a data structure in the form of:

type Connection struct {
	FromNode  string `gd:"from_node"`
	FromPort  int    `gd:"from_port"`
	ToNode    string `gd:"to_node"`
	ToPort    int    `gd:"to_port"`
	KeepAlive bool   `gd:"keep_alive"`
}

func (Instance) GetElementFrame

func (self Instance) GetElementFrame(element string) GraphFrame.Instance

Returns the GraphFrame that contains the GraphElement with the given name.

func (Instance) GetMenuHbox

func (self Instance) GetMenuHbox() HBoxContainer.Instance

Gets the HBoxContainer that contains the zooming and grid snap controls in the top left of the graph. You can use this method to reposition the toolbar or to add your own custom controls to it.

Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.Visible property.

func (Instance) GridPattern

func (self Instance) GridPattern() GridPattern

The pattern used for drawing the grid.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsNodeConnected

func (self Instance) IsNodeConnected(from_node string, from_port int, to_node string, to_port int) bool

Returns true if the 'from_port' of the 'from_node' GraphNode is connected to the 'to_port' of the 'to_node' GraphNode.

func (Instance) IsValidConnectionType

func (self Instance) IsValidConnectionType(from_type int, to_type int) bool

Returns whether it's possible to make a connection between two different port types. The port type is defined individually for the left and the right port of each slot with the GraphNode.SetSlot method.

See also AddValidConnectionType and RemoveValidConnectionType.

func (Instance) MinimapEnabled

func (self Instance) MinimapEnabled() bool

If true, the minimap is visible.

func (Instance) MinimapOpacity

func (self Instance) MinimapOpacity() Float.X

The opacity of the minimap rectangle.

func (Instance) MinimapSize

func (self Instance) MinimapSize() Vector2.XY

The size of the minimap rectangle. The map itself is based on the size of the grid area and is scaled to fit this rectangle.

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) OnBeginNodeMove

func (self Instance) OnBeginNodeMove(cb func(), flags ...Signal.Flags)

Emitted at the beginning of a GraphElement's movement.

func (Instance) OnConnectionDragEnded

func (self Instance) OnConnectionDragEnded(cb func(), flags ...Signal.Flags)

Emitted at the end of a connection drag.

func (Instance) OnConnectionDragStarted

func (self Instance) OnConnectionDragStarted(cb func(from_node string, from_port int, is_output bool), flags ...Signal.Flags)

Emitted at the beginning of a connection drag.

func (Instance) OnConnectionFromEmpty

func (self Instance) OnConnectionFromEmpty(cb func(to_node string, to_port int, release_position Vector2.XY), flags ...Signal.Flags)

Emitted when user drags a connection from an input port into the empty space of the graph.

func (Instance) OnConnectionRequest

func (self Instance) OnConnectionRequest(cb func(from_node string, from_port int, to_node string, to_port int), flags ...Signal.Flags)

Emitted to the GraphEdit when the connection between the 'from_port' of the 'from_node' GraphNode and the 'to_port' of the 'to_node' GraphNode is attempted to be created.

func (Instance) OnConnectionToEmpty

func (self Instance) OnConnectionToEmpty(cb func(from_node string, from_port int, release_position Vector2.XY), flags ...Signal.Flags)

Emitted when user drags a connection from an output port into the empty space of the graph.

func (Instance) OnCopyNodesRequest

func (self Instance) OnCopyNodesRequest(cb func(), flags ...Signal.Flags)

Emitted when this GraphEdit captures a ui_copy action (Ctrl + C by default). In general, this signal indicates that the selected GraphElements should be copied.

func (Instance) OnCutNodesRequest

func (self Instance) OnCutNodesRequest(cb func(), flags ...Signal.Flags)

Emitted when this GraphEdit captures a ui_cut action (Ctrl + X by default). In general, this signal indicates that the selected GraphElements should be cut.

func (Instance) OnDeleteNodesRequest

func (self Instance) OnDeleteNodesRequest(cb func(nodes []string), flags ...Signal.Flags)

Emitted when this GraphEdit captures a ui_graph_delete action (Delete by default).

'nodes' is an array of node names that should be removed. These usually include all selected nodes.

func (Instance) OnDisconnectionRequest

func (self Instance) OnDisconnectionRequest(cb func(from_node string, from_port int, to_node string, to_port int), flags ...Signal.Flags)

Emitted to the GraphEdit when the connection between 'from_port' of 'from_node' GraphNode and 'to_port' of 'to_node' GraphNode is attempted to be removed.

func (Instance) OnDuplicateNodesRequest

func (self Instance) OnDuplicateNodesRequest(cb func(), flags ...Signal.Flags)

Emitted when this GraphEdit captures a ui_graph_duplicate action (Ctrl + D by default). In general, this signal indicates that the selected GraphElements should be duplicated.

func (Instance) OnEndNodeMove

func (self Instance) OnEndNodeMove(cb func(), flags ...Signal.Flags)

Emitted at the end of a GraphElement's movement.

func (Instance) OnFrameRectChanged

func (self Instance) OnFrameRectChanged(cb func(frame_ GraphFrame.Instance, new_rect Rect2.PositionSize), flags ...Signal.Flags)

Emitted when the GraphFrame 'frame' is resized to 'new_rect'.

func (Instance) OnGraphElementsLinkedToFrameRequest

func (self Instance) OnGraphElementsLinkedToFrameRequest(cb func(elements []any, frame_ string), flags ...Signal.Flags)

Emitted when one or more GraphElements are dropped onto the GraphFrame named 'frame', when they were not previously attached to any other one.

'elements' is an array of GraphElements to be attached.

func (Instance) OnNodeDeselected

func (self Instance) OnNodeDeselected(cb func(node Node.Instance), flags ...Signal.Flags)

Emitted when the given GraphElement node is deselected.

func (Instance) OnNodeSelected

func (self Instance) OnNodeSelected(cb func(node Node.Instance), flags ...Signal.Flags)

Emitted when the given GraphElement node is selected.

func (Instance) OnPasteNodesRequest

func (self Instance) OnPasteNodesRequest(cb func(), flags ...Signal.Flags)

Emitted when this GraphEdit captures a ui_paste action (Ctrl + V by default). In general, this signal indicates that previously copied GraphElements should be pasted.

func (Instance) OnPopupRequest

func (self Instance) OnPopupRequest(cb func(at_position Vector2.XY), flags ...Signal.Flags)

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

func (Instance) OnScrollOffsetChanged

func (self Instance) OnScrollOffsetChanged(cb func(offset Vector2.XY), flags ...Signal.Flags)

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

func (Instance) PanningScheme

func (self Instance) PanningScheme() PanningScheme

Defines the control scheme for panning with mouse wheel.

func (Instance) RemoveValidConnectionType

func (self Instance) RemoveValidConnectionType(from_type int, to_type int)

Disallows the connection between two different port types previously allowed by AddValidConnectionType. The port type is defined individually for the left and the right port of each slot with the GraphNode.SetSlot method.

See also IsValidConnectionType.

func (Instance) RemoveValidLeftDisconnectType

func (self Instance) RemoveValidLeftDisconnectType(atype int)

Disallows to disconnect nodes when dragging from the left port of the GraphNode's slot if it has the specified type. Use this to disable disconnection previously allowed with AddValidLeftDisconnectType.

func (Instance) RemoveValidRightDisconnectType

func (self Instance) RemoveValidRightDisconnectType(atype int)

Disallows to disconnect nodes when dragging from the right port of the GraphNode's slot if it has the specified type. Use this to disable disconnection previously allowed with AddValidRightDisconnectType.

func (Instance) RightDisconnects

func (self Instance) RightDisconnects() bool

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

func (Instance) ScrollOffset

func (self Instance) ScrollOffset() Vector2.XY

The scroll offset.

func (Instance) SetConnectionActivity

func (self Instance) SetConnectionActivity(from_node string, from_port int, to_node string, to_port int, amount Float.X)

Sets the coloration of the connection between 'from_node”s 'from_port' and 'to_node”s 'to_port' with the color provided in the theme's 'activity' theme property. The color is linearly interpolated between the connection color and the activity color using 'amount' as weight.

func (Instance) SetConnectionLinesAntialiased

func (self Instance) SetConnectionLinesAntialiased(value bool)

SetConnectionLinesAntialiased sets the property returned by [IsConnectionLinesAntialiased].

func (Instance) SetConnectionLinesCurvature

func (self Instance) SetConnectionLinesCurvature(value Float.X)

SetConnectionLinesCurvature sets the property returned by [GetConnectionLinesCurvature].

func (Instance) SetConnectionLinesThickness

func (self Instance) SetConnectionLinesThickness(value Float.X)

SetConnectionLinesThickness sets the property returned by [GetConnectionLinesThickness].

func (Instance) SetConnections

func (self Instance) SetConnections(value []Connection)

SetConnections sets the property returned by [GetConnectionList].

func (Instance) SetGridPattern

func (self Instance) SetGridPattern(value GridPattern)

SetGridPattern sets the property returned by [GetGridPattern].

func (Instance) SetMinimapEnabled

func (self Instance) SetMinimapEnabled(value bool)

SetMinimapEnabled sets the property returned by [IsMinimapEnabled].

func (Instance) SetMinimapOpacity

func (self Instance) SetMinimapOpacity(value Float.X)

SetMinimapOpacity sets the property returned by [GetMinimapOpacity].

func (Instance) SetMinimapSize

func (self Instance) SetMinimapSize(value Vector2.XY)

SetMinimapSize sets the property returned by [GetMinimapSize].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPanningScheme

func (self Instance) SetPanningScheme(value PanningScheme)

SetPanningScheme sets the property returned by [GetPanningScheme].

func (Instance) SetRightDisconnects

func (self Instance) SetRightDisconnects(value bool)

SetRightDisconnects sets the property returned by [IsRightDisconnectsEnabled].

func (Instance) SetScrollOffset

func (self Instance) SetScrollOffset(value Vector2.XY)

SetScrollOffset sets the property returned by [GetScrollOffset].

func (Instance) SetSelected

func (self Instance) SetSelected(node Node.Instance)

Sets the specified 'node' as the one selected.

func (Instance) SetShowArrangeButton

func (self Instance) SetShowArrangeButton(value bool)

SetShowArrangeButton sets the property returned by [IsShowingArrangeButton].

func (Instance) SetShowGrid

func (self Instance) SetShowGrid(value bool)

SetShowGrid sets the property returned by [IsShowingGrid].

func (Instance) SetShowGridButtons

func (self Instance) SetShowGridButtons(value bool)

SetShowGridButtons sets the property returned by [IsShowingGridButtons].

func (Instance) SetShowMenu

func (self Instance) SetShowMenu(value bool)

SetShowMenu sets the property returned by [IsShowingMenu].

func (Instance) SetShowMinimapButton

func (self Instance) SetShowMinimapButton(value bool)

SetShowMinimapButton sets the property returned by [IsShowingMinimapButton].

func (Instance) SetShowZoomButtons

func (self Instance) SetShowZoomButtons(value bool)

SetShowZoomButtons sets the property returned by [IsShowingZoomButtons].

func (Instance) SetShowZoomLabel

func (self Instance) SetShowZoomLabel(value bool)

SetShowZoomLabel sets the property returned by [IsShowingZoomLabel].

func (Instance) SetSnappingDistance

func (self Instance) SetSnappingDistance(value int)

SetSnappingDistance sets the property returned by [GetSnappingDistance].

func (Instance) SetSnappingEnabled

func (self Instance) SetSnappingEnabled(value bool)

SetSnappingEnabled sets the property returned by [IsSnappingEnabled].

func (Instance) SetTypeNames

func (self Instance) SetTypeNames(value map[int]string)

SetTypeNames sets the property returned by [GetTypeNames].

func (Instance) SetZoom

func (self Instance) SetZoom(value Float.X)

SetZoom sets the property returned by [GetZoom].

func (Instance) SetZoomMax

func (self Instance) SetZoomMax(value Float.X)

SetZoomMax sets the property returned by [GetZoomMax].

func (Instance) SetZoomMin

func (self Instance) SetZoomMin(value Float.X)

SetZoomMin sets the property returned by [GetZoomMin].

func (Instance) SetZoomStep

func (self Instance) SetZoomStep(value Float.X)

SetZoomStep sets the property returned by [GetZoomStep].

func (Instance) ShowArrangeButton

func (self Instance) ShowArrangeButton() bool

If true, the button to automatically arrange graph nodes is visible.

func (Instance) ShowGrid

func (self Instance) ShowGrid() bool

If true, the grid is visible.

func (Instance) ShowGridButtons

func (self Instance) ShowGridButtons() bool

If true, buttons that allow to configure grid and snapping options are visible.

func (Instance) ShowMenu

func (self Instance) ShowMenu() bool

If true, the menu toolbar is visible.

func (Instance) ShowMinimapButton

func (self Instance) ShowMinimapButton() bool

If true, the button to toggle the minimap is visible.

func (Instance) ShowZoomButtons

func (self Instance) ShowZoomButtons() bool

If true, buttons that allow to change and reset the zoom level are visible.

func (Instance) ShowZoomLabel

func (self Instance) ShowZoomLabel() bool

If true, the label with the current zoom level is visible. The zoom level is displayed in percents.

func (Instance) SnappingDistance

func (self Instance) SnappingDistance() int

The snapping distance in pixels, also determines the grid line distance.

func (Instance) SnappingEnabled

func (self Instance) SnappingEnabled() bool

If true, enables snapping.

func (Instance) TypeNames

func (self Instance) TypeNames() map[int]string

data structure of human readable port type names.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) Zoom

func (self Instance) Zoom() Float.X

The current zoom value.

func (Instance) ZoomMax

func (self Instance) ZoomMax() Float.X

The upper zoom limit.

func (Instance) ZoomMin

func (self Instance) ZoomMin() Float.X

The lower zoom limit.

func (Instance) ZoomStep

func (self Instance) ZoomStep() Float.X

The step of each zoom level.

type Interface

type Interface interface {
	// Returns whether the 'mouse_position' is in the input hot zone.
	//
	// By default, a hot zone is a [Rect2.PositionSize] positioned such that its center is at 'in_node'.[GraphNode.GetInputPortPosition]('in_port') (For output's case, call [GraphNode.GetOutputPortPosition] instead). The hot zone's width is twice the Theme Property port_grab_distance_horizontal, and its height is twice the port_grab_distance_vertical.
	//
	// Below is a sample code to help get started:
	//
	//
	//
	// func _is_in_input_hotzone(in_node, in_port, mouse_position):
	//
	// 	var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
	//
	// 	var port_pos = in_node.get_position() + in_node.get_input_port_position(in_port) - port_size / 2
	//
	// 	var rect = Rect2(port_pos, port_size)
	//
	//
	//
	// 	return rect.has_point(mouse_position)
	//
	//
	//
	// [GraphNode.GetInputPortPosition]: https://pkg.go.dev/graphics.gd/classdb/GraphNode#Instance.GetInputPortPosition
	// [GraphNode.GetOutputPortPosition]: https://pkg.go.dev/graphics.gd/classdb/GraphNode#Instance.GetOutputPortPosition
	// [Rect2.PositionSize]: https://pkg.go.dev/graphics.gd/variant/Rect2#PositionSize
	IsInInputHotzone(in_node Object.Instance, in_port int, mouse_position Vector2.XY) bool
	// Returns whether the 'mouse_position' is in the output hot zone. For more information on hot zones, see [IsInInputHotzone].
	//
	// Below is a sample code to help get started:
	//
	//
	//
	// func _is_in_output_hotzone(in_node, in_port, mouse_position):
	//
	// 	var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
	//
	// 	var port_pos = in_node.get_position() + in_node.get_output_port_position(in_port) - port_size / 2
	//
	// 	var rect = Rect2(port_pos, port_size)
	//
	//
	//
	// 	return rect.has_point(mouse_position)
	//
	//
	//
	// [IsInInputHotzone]: https://pkg.go.dev/graphics.gd/classdb/GraphEdit#Interface
	IsInOutputHotzone(in_node Object.Instance, in_port int, mouse_position Vector2.XY) bool
	// Virtual method which can be overridden to customize how connections are drawn.
	GetConnectionLine(from_position Vector2.XY, to_position Vector2.XY) []Vector2.XY
	// This virtual method can be used to insert additional error detection while the user is dragging a connection over a valid port.
	//
	// Return true if the connection is indeed valid or return false if the connection is impossible. If the connection is impossible, no snapping to the port and thus no connection request to that port will happen.
	//
	// In this example a connection to same node is suppressed:
	//
	//
	//
	// [gdscript]
	//
	// func _is_node_hover_valid(from, from_port, to, to_port):
	//
	// 	return from != to
	//
	// [/gdscript]
	//
	// [csharp]
	//
	// public override bool _IsNodeHoverValid(StringName fromNode, int fromPort, StringName toNode, int toPort)
	//
	// {
	//
	// 	return fromNode != toNode;
	//
	// }
	//
	// [/csharp]
	//
	//
	IsNodeHoverValid(from_node string, from_port int, to_node string, to_port int) bool
}

type MoreArgs

type MoreArgs [1]gdclass.GraphEdit

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) ConnectNode

func (self MoreArgs) ConnectNode(from_node string, from_port int, to_node string, to_port int, keep_alive bool) error

Create a connection between the 'from_port' of the 'from_node' GraphNode and the 'to_port' of the 'to_node' GraphNode. If the connection already exists, no connection is created.

Connections with 'keep_alive' set to false may be deleted automatically if invalid during a redraw.

func (MoreArgs) GetClosestConnectionAtPoint

func (self MoreArgs) GetClosestConnectionAtPoint(point Vector2.XY, max_distance Float.X) Connection

Returns the closest connection to the given point in screen space. If no connection is found within 'max_distance' pixels, an empty data structure is returned.

A connection is represented as a data structure in the form of:

type Connection struct {
	FromNode  string `gd:"from_node"`
	FromPort  int    `gd:"from_port"`
	ToNode    string `gd:"to_node"`
	ToPort    int    `gd:"to_port"`
	KeepAlive bool   `gd:"keep_alive"`
}

For example, getting a connection at a given mouse position can be achieved like this:

type PanningScheme

type PanningScheme int //gd:GraphEdit.PanningScheme
const (
	// Mouse Wheel will zoom, Ctrl + Mouse Wheel will move the view.
	ScrollZooms PanningScheme = 0
	// Mouse Wheel will move the view, Ctrl + Mouse Wheel will zoom.
	ScrollPans PanningScheme = 1
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL