check marks in a 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
marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

check marks in a list

Post by marksmithhfx » Fri Dec 02, 2011 2:09 am

Hi, I have a list field where you can select items and then do things (on a separate card). I am looking for ideas on how I might be able to put a "check mark" beside an item in the list, like this:

item 1 ✓
item 2 ✓
item 3
item 4
item 5 ✓

Any suggestions?

Thanks

-- Mark

PS application is destined for iOS so I guess if I use a font that might be an issue?
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

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

Re: check marks in a list

Post by Mark » Fri Dec 02, 2011 3:04 am

Hi Mark,

For this, I use a field with small icons. I set the imageSource of a character to the id of an image and if the user presses on it, I change the id. You might want to check the clickText.

Alternatively, you could use the datagrid.

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: check marks in a list

Post by dunbarx » Fri Dec 02, 2011 5:25 am

Couldn't you just append the checkmark itself (ASCII 195)?

Craig Newman

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: check marks in a list

Post by jacque » Fri Dec 02, 2011 8:57 pm

dunbarx wrote:Couldn't you just append the checkmark itself (ASCII 195)?

Craig Newman
I actually do that a lot in my own stuff, it's handy, but really that's a square root symbol so in production work I'd use an image.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am

Re: check marks in a list

Post by marksmithhfx » Fri Dec 02, 2011 11:28 pm

jacque wrote:
dunbarx wrote:Couldn't you just append the checkmark itself (ASCII 195)?

Craig Newman
I actually do that a lot in my own stuff, it's handy, but really that's a square root symbol so in production work I'd use an image.
Thanks Mark, Craig and Jacque. For the quick demo I was pulling together I was actually concerned about using the imagesource idea having never tried it before so I went the route of just overlaying some checkbox buttons on the list (I was surprised that worked. Really surprised, but it did and was simple to script the status of each check). Now that I have some time to explore I'll look further into imagesource and clicktext.

I have a related question. I also wanted to "sum" the number of items checked, for example in my original post the sum would be 3. I put together the following loop that works fine but wondered if there is wasn't an easier (single statement) way to do the same thing...

Code: Select all

  put 0 into s
   repeat with x = 1 to 6
      put "check" into temp
      put x after temp
      if the hilite of btn temp is true then 
         add 1 to s
      end if
   end repeat
I was hoping something like

Code: Select all

 put sum(btn "check1", btn "check2") into s -- assuming TRUE = 1, FALSE = 0 
might work, but it didn't. Any other options?

Thanks
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

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

Re: check marks in a list

Post by Mark » Sat Dec 03, 2011 1:27 am

Mark,

Since you're using checkboxes, you need to use a repeat loop. If you were using radiobuttons, then you might have been able to use the selectedButton or hilitedButton. The selectedButton does work with checkboxes, but it always returns only one object reference.

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

Post Reply