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

Change Button fill color and color in Button click

I have 3 buttons here. When I click on button 1 , the background of button need to change it to blue and others are white. And again when I click on button 2, then  button 1 and button 3 should be white and button 2 background should be blue. Please suggest , how to do it. 

My requirement is to show the current selected button. 

Now when I select button 1 , all button color get changed to blue but I need only selected one. 

rswain44_0-1598652332704.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

@rswain44 ,

You need two Variables

On button 1

UpdateContext(
   {
      OneClicked:true, 
      TwoClicked,false
   }
)

Button 2

UpdateContext(
   {
      TwoClicked:true, 
      OneClicked,false
   }
)

Fill of Button 1

If(
   OneClicked
   MidnightBlue,
   White
)

Then button 2 Fill

If(
   TwoClicked
   MidnightBlue,
   White
)

I am assuming Button 3 simply stays white.

This is a logic more than a coding/syntax issue - the above should work, but I am sure you will get the idea.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

4 REPLIES 4
WarrenBelz
Super User
Super User

Hi @rswain44 ,

Set some Variables on the OnSelect of the buttons

UpdateContext({OneClicked:true})

Then the Fill of Button 1

If(
   OneClicked,
   Blue,
   White
)

An so on for the others - ensure you set the variables to false on screen entry.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 ,

 

I am not sure i am doing it in right way. Please check once.

Step 1: In button 1 -OnSelect-- UpdateContext({CurrentSelect:true})   --------I Added this formula

Step 2: In button 1 -fill - I added below formula.

 

If(
   CurrentSelect,
   MidnightBlue,
   White
   
)

 

Step 3: Next in button 2--onselect- I Added this formula--Set(CurrentSelect,"false") 

Step 4: button 2 --Fill-- I added the same code which I added in button 1 fill .

Finally its not working. I am sure , i did something wrong here. Please advise.

issue2.JPG

 

Now my all buttons are changed to blue and no color change after click on any button.  

@rswain44 ,

You need two Variables

On button 1

UpdateContext(
   {
      OneClicked:true, 
      TwoClicked,false
   }
)

Button 2

UpdateContext(
   {
      TwoClicked:true, 
      OneClicked,false
   }
)

Fill of Button 1

If(
   OneClicked
   MidnightBlue,
   White
)

Then button 2 Fill

If(
   TwoClicked
   MidnightBlue,
   White
)

I am assuming Button 3 simply stays white.

This is a logic more than a coding/syntax issue - the above should work, but I am sure you will get the idea.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Brendan_Val
New Member

How do you reset the button variable OneClicked and TwoClicked when changing pages?

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,732)