Skip to main content
Participating Frequently
March 3, 2021
Answered

Click button once, twice, ... to show different symbols

  • March 3, 2021
  • 1 reply
  • 2615 views

Hello everyone, is it possible to create a button which shows symbol A when being clicked once, symbol B when being clicked twice and symbol C when being clicked for the third time?

I also have some troubles finding the right symbols for my case. I need a checkmark, an exclamation mark and a slash. I thought, maybe it would be the best solution, if I could let show the symbols as pictures.

In conclusion, that would mean: First Click -> Pic 1, Second Click -> Pic 2, Third Click -> Pic 3. The images should appear in the same place so that they are mutually exclusive.

 

I would be very grateful for a helpful answer!
This topic has been closed for replies.
Correct answer Nesa Nurani

Thanks for the answer! I suppose it would be helpful if I understood it. Would it be possible for you to rewrite my script as you mean it. Unfortunately, I have absolutely no idea about it and am still at the very beginning to learn it.


You can try this code:

if(event.target.buttonGetCaption()==""){
event.target.buttonSetCaption("✔");
event.target.textColor = color.green;}
else if(event.target.buttonGetCaption()=="✔") {
event.target.buttonSetCaption("!");
event.target.textColor = color.red;}
else if(event.target.buttonGetCaption()=="!"){
event.target.buttonSetCaption("/");
event.target.textColor = color.black;}
else if(event.target.buttonGetCaption()=="/")
event.target.buttonSetCaption("");

1 reply

try67
Community Expert
Community Expert
March 3, 2021

Search the forum for "tri-state field". This issue was discussed many times in the past, and there are complete code samples on how to do it.

Alina5C99Author
Participating Frequently
April 9, 2021

Many thanks for the answer. The tip helped me a lot. I only have one more question: Is it also possible that the field starts empty at first? So, if you haven't clicked anything yet, the button is empty/blank. And only when you click once does a tick appear and so on ... That would be very important for my client. At the moment there is a green checkmark in every field from the start, without anything being clicked. This is the script, I used/copied from another thread: 

 

if(color.equal(event.target.textColor,color.black))
{
event.target.textColor = color.green;
event.target.buttonSetCaption("✔");
}
else if(color.equal(event.target.textColor,color.green))
{
event.target.textColor = color.red;
event.target.buttonSetCaption("!");
}
else
{
event.target.textColor = color.black;
event.target.buttonSetCaption("/");
}

Inspiring
April 9, 2021

Where and how do you use that script and what font do you use?