CheckBox functionality in List

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
larryGAab48
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6
Joined: Mon Dec 05, 2011 5:33 pm

CheckBox functionality in List

Post by larryGAab48 » Mon Feb 20, 2012 6:32 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: CheckBox functionality in List

Post by Mark » Mon Feb 20, 2012 8:19 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

larryGAab48
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6
Joined: Mon Dec 05, 2011 5:33 pm

Re: CheckBox functionality in List

Post by larryGAab48 » Tue Feb 21, 2012 1:04 pm

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

Post Reply