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?
Solved! Go to Solution.
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!
Have a nice day.
Good nite.
Hi
Each button has many variable for you to control:
- PressedFill
- PressedColor
You can make changes over the color as you wish.
TQ
If you want to change the color of the button while it's pressed, you can change the PressedColor (for the font color) and PressedFill (for the background color) of the button.
If you want to use the button as a toggle so that anytime it is pressed it will change the color of either the button itself or another control, you can use a context variable that is toggled in the OnSelect handler of the button. For example, if you want to use the button to toggle the color of itself and another control (say, a text box), you would use those formulas:
Button1.OnSelect: UpdateContext({ toggleValue: !toggleValue }) Button1.Color: If(toggleValue, Color.White, Color.Yellow) Button1.Fill: If(toggleValue, Color.Blue, Color.Green) TextBox1.Color: If(toggleValue, Color.Black, Color.White) TextBox1.Fill: If(toggleValue, Color.White, Color.Black)
You can find the options mentioned by the other users by:
It came up with an error, I copy and pasted it into the Action On Select part.
Thanks for you help everyone with this
Hi
You might have misunderstood Carlos.
1. Select the Button (which you wish to click), you can see OnSelect (Left Hand Side pane), and fill-in
UpdateContext({togglevalue: !togglevalue}) next to the box of fx.b
2. On the Left Pane again, look for Color & Fill and fill-in as:
Color (of the font inside the Button)...box next to fx: If(togglevalue, Color.White, Color. Yello})...or any color you wish
Fill... (fill of the Button)...box next to fx: If(togglevalue, Color.Green, Color.Red).....or any color you wish
TextBox1 (Color, Color, Border,...). as above
and any other.
You can change almost everything as long the you had accomplished No. 1: UpdateContext({togglevalue: !togglevalue}).
Note:
1. togglevalue is a Context Variable, you assign to the Button to toggle true and false when you click.
2. ! means reverse to the first value. If true, then false, if false, then true, and vice versa.
3. This Context Variable only works in the SAME SCREEN.
3. If(togglervalue,....) here togglevalue measn true
Hope this can clarify the whole scenario from Carlos.
Bugger, I realy don't know what I'm doing here. I think I made a mess of it :0(
Hi
I did more mistake than you and misunderstood of what they said initially.
If you are catching up faster than be before.
Keep it up....Will always share to learn together.
Have a beautiful Sunday.
(Listen to Bonnie M)
Ok how woud you expand this to cycle through say 3 colours? I have a round shape, that each time the user selects it, i want it to cycle through Green, Orange, Red.
Hi @JC75
You have to use:
- Timer
- Set the Circle.Fill =
If(Timer1_1.Value <= 1000, Color.Green, Timer1_1.Value > 1000 && Timer1_1.Value <= 2000, Color.Orange, Color.Red)
Then, set your own Duration, Repeat, Autostart, ....
Example: Circle.OnSelect = UpdateContext({clickme1: !clickme1})
where clickme1 is the variable for Timer1_1
- Timer1_1.Start = clickme1.
Anyway, it is up to you to design.
Click on circle, and start
Hope this helps.
TQ
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
209 | |
47 | |
43 | |
41 | |
36 |
User | Count |
---|---|
290 | |
84 | |
81 | |
79 | |
77 |