Topic was automatically imported from the old Question2Answer platform.
Asked By
patlol
Hello,
I would like to change the background color of some of the controls in my GUI (LineEdit, ItemList…).
For example on a LineEdit the background color is grey, I attach a script to this control:
extends LineEdit
var my_style = StyleBoxFlat.new()
func _ready():
my_style.set_bg_color(Color(0,1,1,1))
But nothing changes and there is no error message. I didn’t find an example in the doc. Where is my mistake.
Thank you.
You seem to be creating a new style, but not assigning it to any of the custom styles properties:
extends LineEdit
var my_style = StyleBoxFlat.new()
func _ready():
my_style.set_bg_color(Color(0,1,1,1))
# Set the "normal" style to be your newly created style.
set("custom_styles/normal", my_style)
I’ve never actually used these so I can’t guarantee that the code above is the correct syntax, but I’m quite sure you need to be setting a property to the new style, otherwise it won’t be used. Hope this helps.