Godot: get_stylebox("myStyle") doesn't always get the correct type.

Created on 24 Feb 2015  路  10Comments  路  Source: godotengine/godot

An example...

Say I made a progress bar, and I gave it my own style using the "newStyleBoxFlat" entry.

Now say I fetch the bar node using GDscript and used this code...

var Style = myBar.get_stylebox("myFlatStyle")
print(Style)

The print will give me "StyleBoxTextured:#" when it should be saying "StyleBoxFlat:#", as a result, I cannot change the color because the function for that is only for flat styles and the engine thinks I'm using the Textured type..

This shouldn't be too hard to fix I think, thanks.

documentation enhancement junior job

Most helpful comment

Sounds like a documentation improvement is in order.

All 10 comments

not sure if i understand this bug, did you give it your own style using code?

The simplest possible test case
http://www.mediafire.com/download/fciqbi9dw8jn5t8/UI_Test.zip

When you play the file, it is clear the stylebox type for the bar graphic is flat, but the debug output shows that the function doesn't recognize that and instead says the stylebox type is textured.

Confirmed in the current master branch.

First of all thank you for your report and sorry for the delay.

We released Godot 3.0 in January 2018 after 18 months of work, fixing many old issues either directly, or by obsoleting/replacing the features they were referring to.

We still have hundreds of issues whose relevance/reproducibility needs to be checked against the current stable version, and that's where you can help us.
Could you check if the issue that you described initially is still relevant/reproducible in Godot 3.0 or any newer version, and comment about it here?

For bug reports, please also make sure that the issue contains detailed steps to reproduce the bug and, if possible, a zipped project that can be used to reproduce it right away. This greatly speeds up debugging and bugfixing tasks for our contributors.

Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed.

Thanks in advance.

Note: This message is being copy-pasted to many "stale" issues (90+ days without activity). It might happen that it is not meaningful for this specific issue or appears oblivious of the issue's context, if so please comment to notify the Bugsquad about it.

ProgressBar really uses StyleBoxTextured by default, but in UI_Test.zip shows an incorrect usage

func _fixed_process(delta):
    var myBox = get_node("ProgressBar")
    var Style = myBox.get_stylebox("myFlatStyle")
    print(Style)

there is no "myFlatStyle" stylebox in ProgressBar now. The correct usage is

var Style = myBox.get_stylebox("fg")

which is correctly handled as StyleBoxFlat or whatever you apply to it. Closed.

For anyone still coming here: the string passed as the first argument to get_stylebox() is NOT the resource's name, but the name when hovering the name of the node, near the checkbox (Godot 3.2.2). In my case, I had to hover over "Panel", and calling get_stylebox("panel") yields the correct StyleBox. I hope this helps someone out there.

THANK YOU! You just saved me many hours of head-scratching and expletive outbursts!

Sounds like a documentation improvement is in order.

Hi, I'm interested in updating the documentation here. Quick clarifying question: Has the get_stylebox() method been renamed to get_theme_stylebox()? I'm unable to find the get_stylebox() method in the current Control.xml. Admittedly, I may be looking in the wrong class.

@zak-grumbles Yes, all the theme item getter methods have been renamed from get_<item>() to get_theme_<item>() in the master branch.

Make sure to open the pull request against the master branch. We can cherry-pick it to the 3.2 branch ourselves once it's merged.

Was this page helpful?
0 / 5 - 0 ratings