Need help with adding GraphNodes to a GraphFrame

Godot Version

4.3

Question

So I’m creating a dialog graph system in Godot and I am trying to recreate the functionality that the visual shader editor has where you can place and connect GraphNodes inside of a GraphFrame. While I can add my custom nodes to a frame, I can’t seem to be able to move them inside the frame or even grab the connections slots/ports. I checked the documentation but it doesn’t say anything about how to properly add and move nodes inside of a frame. I also made sure to correctly set the mouse_filter and selectable boolean of the nodes after they are placed in the frame but they still aren’t selectable. But the buttons inside of the graph nodes are still. Is this an issue of the graph node no longer being inside of a GraphEdit and therefore doesn’t have a position offset? I unfortunately cannot upload any videos demonstrating the issue as I am a new user. Any assistance would be greatly appreciated, thank you.

1 Like

I’m just writing to say that I have the same issue. When graph nodes are in a graph frame I can’t connect them anymore. I’ve also checked mouse filter and selectable.

GraphFrame in Godot is not equivalent to GraphEdit in terms of functionality. GraphFrame is primarily a visual/cosmetic element used within GraphEdit to visually group nodes, but it doesn’t provide the interactive canvas functionality that GraphEdit does.

When you place GraphNodes directly inside a GraphFrame without a parent GraphEdit, you’re missing:

The position management system (position_offset) that GraphEdit provides
The connection handling system
The selection and dragging functionality

If you wanna do a custom implementation youll have to do something like this.

Create a proper structure:

GraphEdit (main editor canvas)
├── GraphNode 1
├── GraphNode 2
└── GraphFrame
├── GraphNode 3
└── GraphNode 4

Or you could use code and do something like:

extends GraphEdit

func _ready():
    # Create a frame
    var frame = GraphFrame.new()
    add_child(frame)
    
    # Create nodes inside the frame
    var node1 = GraphNode.new() 
    node1.title = "Node in Frame"
    node1.position_offset = Vector2(50, 50)
    frame.add_child(node1)
    
    # Make sure connections work
    connect("connection_request", self, "_on_connection_request")
1 Like

GraphEdit expects connection slots to be on its direct children. When nodes are in a GraphFrame, the connection slots’ positions are calculated incorrectly or events aren’t properly propagated. The connection points’ positions are calculated relative to the GraphEdit, but the nesting inside a GraphFrame changes the coordinate space. The GraphFrame might be intercepting or modifying the mouse events that GraphEdit relies on for connection management. Its a little confusing because they are both “GraphX’s” but they really arent the same thing or even really used together.

1 Like

Thanks a lot @noaht5.1999 . The issue is indeed the expectation that the GraphFrame would behave like Vbox and Hbox.

I’m new to Godot, so I don’t know the conventions of the Godot project, but it’s hard to convey that visually grouping nodes in this way is different than with other methods that logically group child nodes and ‘know’ about them.

I used your suggested structure and it organises my nodes well enough, but it doesn’t feel super elegant. I suppose that’s why there are warnings in the interface that the API is likely to change a lot.

1 Like