The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+2 votes

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 =

func _ready():

But nothing changes and there is no error message. I didn't find an example in the doc. Where is my mistake.
Thank you.

in Engine by (73 points)

2 Answers

+9 votes
Best answer

You seem to be creating a new style, but not assigning it to any of the custom styles properties:

extends LineEdit

var my_style =

func _ready():

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

by (384 points)
selected by
+2 votes

It works perfectly, this kind of thing is apparently difficult to find on the doc.

Thank you so much!

by (73 points)

Please help other by accepting the answer if it solved your problem.
Also please don't post "thank you"s as answers.
Welcome to godot tho :)

It can be very tricky, I found useful to create the same thing in the editor and look at the scene .godot file content, the names are the same

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 [email protected] with your username.