0 votes

I'm new to godot and I'm currently working on an editor using the GraphEdit Node, and I would like to change the border color of a GraphNode via code. Does anyone know how to access that property from code?

in Engine by (106 points)

2 Answers

+1 vote
Best answer

The border color is defined as part of one of the StyleBoxFlats of the GraphNode. To change it, see the GUI theming override demo. You'll need to adapt the code to access the correct stylebox of the GraphNode (most likely the "unselected" one).

by (12,327 points)
selected by

Overriding the theme on the items works.
I used the add_style_override method but I had to create styles for every feature etc.
The correct stylebox in my case was "frame" (as well as "selectedframe" and "defaultfocus").
Thank you very much for the help.

+1 vote

i think by default godot uses a 9 patch texture for its containers. This border color cannot been changed.
You can create a flat-style and set a border. But styles work like shaders. When you chenge it, every instance that it uses would change its appearance.
When i want to change color for selected items i create a style for default and for selected. Then swap the style on the item.

by (4,048 points)

Hello, Thank you for your answer. I think you are right, but it's possible to override the styles using the add_style_override and passing to it a style you created. Once again thank you.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.