How do I access the border color property of a styleboxflat via code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By netimu

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?

:bust_in_silhouette: Reply From: klaas

HI,
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.

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.

netimu | 2020-10-09 18:45

:bust_in_silhouette: Reply From: Calinou

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).

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.

netimu | 2020-10-09 18:42