Download

Check boxes. How to prevent others from checking when one is already checked?

Hi all,

First post here! I´m working on a UMG with 10 checkboxes. Whenever I check one, I want the others not to accept any checking. It sounds easy, and it probably is, but I have done a real mess of nodes and loops to get something semi-working (it kinda works, but it has bugs. It sometimes checks or unchecks the wrong one. It´s a really messy blueprint right now).

Could anybody enlighten me regarding the most usual way to do this? Sounds like something common…

you can add them to an array and before setting them check if any of them are true , But here is the problem with this setup , if player ticks a checkbox and changes his mind and want to tick another he cant do it !

So Add them to an array and before setting any variables , iterate through that array and turn them all false ,Then set the chosen one to true . this way player can choose only 1 and can change his mind after .

Hi. Thanks for the reply. I was already using a similar setup with arrays, but my logic was faulty somewhere. Didn´t find where exactly because today I erased all those nodes, and decided to rethink it from scratch.

Also, because this will be for a mobile game, I don´t want to be able to check another box, until you have unchecked the previous one. That way, if you misclick (mistouch) nothing really happens.
For anyone with the same problem, let me explain what I did because it´s a clean solution and it works very well.

So, I have 9 check boxes, numbered 0-9.
I created TWO variables, which I called “RequestedBox”, and “CheckedBox”. Checked box defaults at 10 (so that by default isn´t any valid number) and RequestedBox defaults at 11 (not important. It just has to be different from the other variable default).
Now, when any of the boxes gets clicked by the user, I store that box value in “RequestedBox”.
If CheckedBox is 10 (everything unchecked), I check the appropiate box (and then I do some other stuff that I need with text inside) and set “CheckedBox” to that number.
If it´s not 10, that means something is already checked, so now I compare if “CheckedBox” and “RequestedBox” are the same number or not.
If they are equal it means the user is clicking on the same box already checked. So I uncheck it, and restore “CheckedBox” to its default value of 10.
If they are NOT equal it means the user clicked some other box different to the checked one, so I uncheck the box the user just clicked (so in effect he´s not doing anything by clicking)

This works wonderfully. Elegant, clear on the BP screen (well…clearer) and simple.
Sometimes coming back with a fresh mind is all you need…

can you make tutorial thank you

Like this perhaps:

If that’s not it, perhaps include some details regarding how it should be working.

This works:


But you can see that you have to add the function to each checkbox event, which is monotonous (however, you can do what Everynone did and bind the events to a single event). Since only one option can selected at a time, consider using a combo box instead, which requires no additional setup.

Here are both in action:
https://streamable.com/8kkiad