Page 1 of 1

CheckBox functionality in List

Posted: Mon Feb 20, 2012 6:32 pm
by larryGAab48
Hello Folks,

Just getting the feet wet with LiveCode, and it's becoming a great learning experience!

As part of the learning process, I'm trying to reconstruct a HandBase app. It's a basic shopping list app that allows the user to add items which can be viewed in a list with checkboxes. Once the item is checked, it is removed from the list and will appear on a “to buy” list. Once unchecked on the to buy list, it will appear once again on the item list. I'm thinking I must be missing something in that I'm not seeing any obvious way of doing this. The Data Grid looks to be an option for the checkbox functionality , but I was thinking that there was probably a simpler way of working this through. I've read some posts about an enhanced scroll list and also a post or two on the mailing list about using in image id to replace a character, but again, I'm thinking there is probably an obvious solution I'm missing.

Any thoughts and direction would be appreciated!

best,
Larry

Re: CheckBox functionality in List

Posted: Mon Feb 20, 2012 8:19 pm
by Mark
Hi Larry,

Why checkboxes? You can make 2 list fields with the following script:

Code: Select all

//field 1
on mouseUp
     if the clickText is not empty then
          if fld 2 is not empty then put cr into myItem
          put the selectedText after myItem
          delete the selectedLine
          put myItem after fld 2
          filter me without empty
          if last char of me is cr then
               delete last char of me
          end if
     end if
end mouseUp

// field 2
on mouseUp
     if the clickText is not empty then
          if fld 1 is not empty then put cr into myItem
          put the selectedText after myItem
          delete the selectedLine
          put myItem after fld 1
          filter me without empty
          if last char of me is cr then
               delete last char of me
          end if
     end if
end mouseUp
Kind regards,

Mark

Re: CheckBox functionality in List

Posted: Tue Feb 21, 2012 1:04 pm
by larryGAab48
Hi Mark,
Many thanks for the response. I appreciate you taking the time for the code as it was very informative.

I'm not sure why I was fixated on the checkboxes themselves, probably because that's what was used in the original app, but your example definitely sent me down the right path. I'm finding that one of my hurdles to overcome with LiveCode is that I'm trying to over-complicate things when there are simpler and more elegant solutions available.

Thanks again for the help. Very instructive!

best to you,
Larry