#2566 Whats the Easiest Way to Color a Buttons Background

JohnNuccio Wed 5 Oct 2016

I am having trouble changing the background color of buttons. What is the best way to accomplish this task?

Also I am trying to modify the text of Buttons when they are clicked. What am I doing wronng?

change := |Event e| { it.text = "change text" }
Button { text = "Something"; onAction.add(change) }

jhughes Wed 5 Oct 2016

For changing the value, the change needs to access the widget that is invoking the action. You can access the widget by just calling widget on the event and since you know the caller is a button you can cast it and work with it.

b := (Button)e.widget
b.text = "change text"

SlimerDude Wed 5 Oct 2016

Hi JohnNuccio,

As for changing the background colour of buttons, I don't believe that's currently possible in fwt.

JohnNuccio Wed 5 Oct 2016

Thanks jhughes for the code, it works perfectly.

Thanks SlimerDude for letting me know that its not possible to change the Background color for Buttons in FTW.

Login or Signup to reply.