531 views
in Getting started by
Hello,

I'd like to change the color of my background every time a user clicks on a button. I was thinking about incrementing an int variable and then creating a new "color string" from this variable.

However, I haven't found any way to convert a string to a color type?!

Thanks.

1 Answer

0 votes
by

Hello,

maybe it is a little bit complexified if you convert an integer into a string and then convert the string into a color.

Let the integer represent the currently selected color number and then just assign the background color according to the currently selected color number:

if ( ColorNumber == 0 )
  Rectangle.Color = #000000FF; // black
else if ( ColorNumber == 1 ) 
  Rectangle.Color = #FF0000FF; // red
else if ( ColorNumber == 2 ) 
  Rectangle.Color = #00FF00FF; // green
else if ( ColorNumber == 3 ) 
  Rectangle.Color = #0000FFFF; // blue
else
  Rectangle.Color = #FFFFFFFF; // white

Does this help?

Best regards,

Manfred.

by
This is a non-solution to me… What am I supposed to do if the user wants to click 250 times on the button ?!
by

In order to make good proposals it is always helpful to understand the entire use-case...

You can create your colors dynamically based on integers by using the color instant constructor.

Does this help?

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...