Skip to first unread message
Assigned to scottfr...@gmail.com by me

omri gal

unread,
Apr 27, 2014, 8:41:15 AM4/27/14
to mitappinv...@googlegroups.com
Hi,

My problem is that in my checkbox list I have 4 options and i want the users to only choose one of option so i did the following (in the screenshot).

The problem was that whenever i checked another box it not only unchecked the previous one but also the one I am choosing so I have to press twice in order for it to work.

I hope hat makes sense it is hard to put it into words for me but I got stuck on it for the last 3 hours and couldn't find anything online. 
I appreciate any help.

Thanks!


   

problem.png

SteveJG

unread,
Apr 27, 2014, 9:00:33 AM4/27/14
to mitappinv...@googlegroups.com
These forum discussions describe using multiple check boxes:    https://groups.google.com/forum/#!searchin/mitappinventortest/radio$20buttons/mitappinventortest/i4MJIXFIWoA/5ac6_9AVz5EJ      or 

They show how you can use multiple linked check boxes..you will have to modify your code to accommodate the algorithm.  First try the code as a separate project,
to make sure this is what you need, then incorporate it into your project.  Make sure you save a copy of your project as an aia file to your PC before you make modifications and/or 
save your existing project on the MIT server using the Save as command option before you start modifying.

Is that what you need?

Regards,
Steve

omri gal

unread,
Apr 27, 2014, 12:55:50 PM4/27/14
to mitappinv...@googlegroups.com
Hey Steve,

Thanks for your quick replay. I read the threads you directed me and even copied your code (added screenshot), but still when Igo to the actual app when I check a box and then check another one both of them get unchecked and I need to press twice for it to work. I'm lost here wondering if you have any other idea. 

I did not copied the "else" section in your example since I saw it was connected to a text label and not an actual check box\button. maybe because of that?  

Thanks in advance I'm trying hard before I post a question.
problem2.png

SteveJG

unread,
Apr 27, 2014, 1:34:06 PM4/27/14
to
Eliminating the else block should not cause an issue.  Your blocks seem OK.  One block must be already checked is the issue.
Initially, ONE of the blocks MUST be checked.


This will work  if initially, the first box is always checked to start.  The user then would select another box. That would allow boxes 3, 4 and 5 to operate as you want.  i suspect the user would 
have to check the first box twice to get it to work,  which is not the response you want.

So, I suggest, you add a fifth checkbox; check it in the Designer, then hide the block in the Properties.  You will never use this hidden block except to get the checkbox. You probably will need this hidden box to get the code to work..  Then you  also have to also set the fifth checkbox to false in each of the four checkboxes.   I see you number your boxes 1,2,4,5   .... there is no checkbox2.     so this extra checkbox will have a different number than checkbox4.

Try some blocks,

Regards,
Steve

Scott Ferguson

unread,
Apr 27, 2014, 6:23:48 PM4/27/14
to mitappinv...@googlegroups.com
Replace 'if true' with 'if CheckBox1.Checked', 'if CheckBox5.Checked', etc. for all of your CheckBox Changed blocks.
---
hAPPy INVENTORing!
Scott

SteveJG

unread,
Apr 28, 2014, 9:19:06 AM4/28/14
to mitappinv...@googlegroups.com
@ Scott... thanks for the suggestion.  It simplifies the code. :)   ...and I discovered you do NOT have to initially check one of the boxes.


Taifun

unread,
Apr 28, 2014, 9:35:37 AM4/28/14
to mitappinv...@googlegroups.com
and if you like to remove some more redundancy, you could use the advanced blocks and define a procedure which unchecks all checkboxes except of the current checkbox and call that procedure in each if statement...
Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.


Reply all
Reply to author
Forward
0 new messages