cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Changing the colour of a button when clicked

Hi

 

 

I've got a button which OnSelect sets a variable which I use later to die or show fields. How would I get the colour of the same button to change when it's clicked? Do I need to select a Property and what would I need to put in it? 

 

Thanks in advance.

3 REPLIES 3
EricLott
Super User
Super User

Buttons have a PressedColor property you can edit. Does that answer your question or do you want the button to toggle colors when it's pressed?

To toggle the button's color, put this formula wherever you see fit (Application's OnStart or Form's OnVisible)

 

ClearCollect(ButtonColors,{Pressed:true,Color:RGBA(255, 0, 0, 1)},{Pressed:false,Color:RGBA(0, 255, 0, 1)});
Set(ButtonPressed,false);

 

Replace the color values with whatever colors you'd like.
Then, on the button you want to toggle, put this formula in the OnSelect property somewhere

 

Set(ButtonPressed,!ButtonPressed);

 

 Finally, on the button's Fill property, put this formula

 

LookUp(ButtonColors,Pressed=ButtonPressed,Color)

 

 

Hi all-

I did exactly as suggested by Eric, but the buttons are just black all the time. Probably a beginner's oversight on my part. Any ideas what to check? Thanks!

Well, it appears as though it worked once I logged out and back in. But now I have another problem.

I have two buttons, but they both change colors as designed using the instructions above. How do I make only the clicked button change?

Button 1 OnSelect action is: Set(ButtonPressed,!ButtonPressed);UpdateContext({FilterByNoticeNeeded:!FilterByNoticeNeeded})

Button 2 OnSelect action is: Set(ButtonPressed,!ButtonPressed);UpdateContext({FilterByNoticeNeeded2:!FilterByNoticeNeeded2})

I am so over my head, but I will learn it!
2021-04-22_13-24-30.jpg

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (34,516)