Hi
I have a simple question, but as i'm new to powerapps, it's not simple to me 🙂
I have 3 buttons, named Red, Green and Blue. When you click on one of these 3 buttons, then a circle should change color and get the color that the button is named. I can only get it to work, so that the circle gets the color when the button is pressed, but when the button is released, then the circle goes back to it's default color, i want it to keep the color until a new button is pressed.
Thanks.
Solved! Go to Solution.
I think it is good, however, to avoid hard code I recommend same formula for each button OnSelect and to use it based on the name of the button they already gave that has the name of the color they want, so for the OnSelect of each button, the same formula can be used as follows:
Set(myColorVar,Self.Text)
However, this assumes that @Rene_Newbee has the literal name of the Button in the Text property (not the name in the Tree view). Otherwise, they should actually either do what you said @SanshubhLubal and hard code it actually, or, they should instead use something like the Tooltip property to put the name of the color, and then use that.
Also, it will not be possible to use the variable by itself in the Fill property of the Circle, the ColorValue function must be used, so like this for the Fill property of the Circle:
ColorValue(myColorVar)
See if it helps @Rene_Newbee
For each button OnSelect property
Set(myColorVar,Self.Text)
For the Circle Fill property
ColorValue(myColorVar)
See if it helps @Rene_Newbee
The result should be like this:
For more info on the functions used, check these guides:
Use a variable on button click: Set(variableName, colour)
Then the circle colour will be your variable.
Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful because this can help others.
LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
Twitter: https://twitter.com/phipps0218
Set variable on all three button's onclick event like this
Red Button : - Set(circlecolor,Red)
Green Button : - Set(circlecolor,green)
Blue Button: - Set(circlecolor,Blue)
and set color property of circle as circlecolor.
I think it is good, however, to avoid hard code I recommend same formula for each button OnSelect and to use it based on the name of the button they already gave that has the name of the color they want, so for the OnSelect of each button, the same formula can be used as follows:
Set(myColorVar,Self.Text)
However, this assumes that @Rene_Newbee has the literal name of the Button in the Text property (not the name in the Tree view). Otherwise, they should actually either do what you said @SanshubhLubal and hard code it actually, or, they should instead use something like the Tooltip property to put the name of the color, and then use that.
Also, it will not be possible to use the variable by itself in the Fill property of the Circle, the ColorValue function must be used, so like this for the Fill property of the Circle:
ColorValue(myColorVar)
See if it helps @Rene_Newbee
I was reading the question and you two gave replies so our answers are kind of same.
@SanshubhLubal You are right. Also, if they meant the Tree view, and they don't want the button's Text property to literally be the name of the Color e.g. "Red", then they either have to put the color in the Tooltip property or some other property and use Self.Tooltip, or, they should actually hard code the colors for each button as inline strings exactly like you said believe it or not. Depending on their preference, you may be right that they should hard code it anyway for the name of the colors.
User | Count |
---|---|
253 | |
125 | |
106 | |
50 | |
49 |