Changing background color šŸš¼

Iā€™m trying to change a background color of the widget on touch and then change it back after 15 sec. I created gv BgColor and set Root background color to this gv $gv(BgColor)$. Then I created a Flow with Manual trigger and action as Formula. But I donā€™t know how to change gv value in the formula.

Well I havenā€™t used Flows for this but I change my background with the following formula (in Background Bitmap) and globals:

$if(gv(bkgd)=Bkgd1,gv(Bkgd1),gv(bkgd)=Bkgd2,gv(Bkgd2),gv(bkgd)=Bkgd3,gv(Bkgd3))$

and I increment the Bkgd# each time I push a button. You should be able to change it to either a fixed or countdown timer easily enough such as:

$if(((df(hh)>12) & (df(hh)<13)) & (gv(bkgd)=xxx), etc. etc. which would only change the background if itā€™s between 12 noon AND 1pm (1300h) AND gv(bkgd)= whatever.

I cannot see where you assign new value to the gv bkgd. The ā€œ=, >, =>ā€ signs are a comparison, not assignment. I need to know a syntax how to chane a value of the variable BgColor in Formula. Thatā€™s it.

Itā€™s in the nested if statement.

Text Globals with some colour:
gv(b1)=#FF003200
gv(b2)=#FFF55555
gv(b3)=#FF861888

List Global:
gv(bkgrd): b1, b2, b3
The colours could be image file paths as well.

((If x = x), then (x=y),
(else if x=y), then (x=z),
(else if x=z), then (x=x))

$if(gv(bkgrd)=b1, gv(b2),
gv(bkgrd)=b2, gv(b3),
gv(bkgrd)=b3, gv(b1))$

This if_then_else statement doesnā€™t have a final else value, so either add one like [,gv(bkgrd)=ā€œā€,gv(b1))$] or skip it altogether if youā€™ve error trapped it enough to avoid a null value.

The if_then_else statement would go in a Color formula field for a shape or background. If youā€™re using images then it would go in the bitmap Pick Image after converting to formula field.

I use a Touch field on a ā€˜buttonā€™ image to toggle ā€˜Next Valueā€™ for the gv(bkgrd) list global but one could use a timer or other trigger as well, or instead of.

Does that help it make sense? Sorry if Iā€™m not clear.

Thank you very much. Itā€™s a good food for my brain :sleeping:. Should experiment little bit :face_with_monocle:.
Iā€™ve got also another interesting and simple solution on reddit. It worked for me:

airizsyah
ā€¢3h agoā€¢Edited 3h ago
Hi there, You can simply create a global switch, name it BgColor, and select auto off > manual and timer > 15. Then, create 2 gv color. (color1 and color2). For the background formula, the formula should be $if(gv(BgColor)=1,gv(color1),gv(color2))$ And set touch action to gv BgColor.

Yes thatā€™s the same as my swapping globals method, except with only two choices instead of three, and the timer option which I mentioned could be combined as well.

And, as you say, experimenting and making mistakes is the only way to get better. Have fun.

This topic was automatically closed 25 days after the last reply. New replies are no longer allowed.