cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

How do you turn a button into a different colour when its pressed?

Hi,

 

I've added a button, what I want it to do is simply toggle between true and false and have it change colour to indicate that when pressed.

 

How do you do that?

19 REPLIES 19
Highlighted

Thank you - that’s a useful example with the timer, however think you missunderstood my request.

 

what I meant was that in your original example, it’s a toggle, so only swaps between two colours each time button is pressed. What I want is that on first click it goes amber, second click red, third click back to green. But remains each colour until clicked, not a cycle through all colours in one go. So having items that can have 3 states rather than just simple true or false.

Highlighted
Community Champion
Community Champion

Hi @JC75

 

Yup, looks like my understanding for English still needs more improvement.

(Maybe I always used to translate in my mind into Chinese when reading).

 

The best and most useful syntax used in PowerApps;

- UpdateContext

- x = x+1 (widely used in any programming languages for Looping purposes

- Switch (If is another alternative, but longer codes)

 

Here it is the final sample and hope this time I have understood your messages.

 

Loop, with unlimited Click; change as you wish!Loop, with unlimited Click; change as you wish!

 

Have a nice day.

Good nite.

hpkeong

View solution in original post

Highlighted

That’s perfect thank you 

Highlighted


@hpkeong wrote:

Hi

 

Each button has many variable for you to control:

- PressedFill

- PressedColor

You can make changes over the color as you wish.

 

TQ


where am i supposed to do this? please help, im a noob in powerapps

Highlighted

@hpkeong I can't see what I'm doing wrong. But it looks like Switch isn't working. The color does not change.

OnSelect.JPGFill.JPG

Highlighted

For anyone else having an issue, I found another solution that works great

colChange.JPG

Highlighted

Hello,

 

Did they change anything in this few years? 

 

When i wanna do "UpdateContext({x: x+1});"

 

im getting syntax error.

 

Btw why everyone post images with code instead of copy it here?....

 

Thanks for answers.

Highlighted

@Corbie your syntax error would be helpful 🙂

Highlighted

@Justair07 

Hello,

 

Sry i figure it out.

 

it was cause of different language in browser.

 

Thanks for answer anyway.

 

 

Highlighted
Continued Contributor
Continued Contributor

My colours are not updating. Is that because I am using a global variable instead of a context variable? Context variable is too limited as I want to pass this value between screens.

    If(daySelected = 2, Color.White, RGBA(255, 255, 255, 1))

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (4,340)