Scrolling variable set of checkboxes

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Adrian
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 79
Joined: Wed Jul 11, 2012 5:03 pm

Scrolling variable set of checkboxes

Post by Adrian » Wed Jul 11, 2012 5:11 pm

Hi all.

As you can see, I am new to this board and new to LiveCode too. I've already had a great deal of help from existing posts, so thanks everyone!

I am investigating one part of an IOS (iPad) app having a scroller which contains a list of items the user can tick off. The list will contain a varying set of values, rather like a shopping list, so the set of options needs to be defined via script. The sort of look I was after is the iOS Reminders app. I'd also like to know (e.g. onCloseCode) which items were ticked off.

Could anyone point me to a way of doing this, either in LiveCode directly, or via an add-on?

Cheers,

Adrian

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Scrolling variable set of checkboxes

Post by BvG » Thu Jul 12, 2012 3:00 pm

In theory the Datagrid in it's "form" style can do that. However, it's most often more efficient to code your own:
  1. Make a bunch of checkmarks, arrange them on top of each other
  2. Group them (button in the Toolbar under the menus that says "group")
  3. Name the group something responsible, and set the vertical scrollbar of it to true (basic inspector tab, "Scrollbar:" "V")
  4. Set the group to the desired rectangle
  5. Important: go to the Size & Position part of the Inspector and check "Lock Size and Position" (LockLoc = true)
If you forget to set the LockLoc, whenever the stack or card opens, the group will be resized to show all the object it contains.

To check the hilite state of the checkmark buttons you have to loop trough them:

Code: Select all

on mouseUp
  repeat with x = the number of buttons in group "myGroup" down to 1
    put the short name of button x of group "myGroup" && the hilite of button x of group "myGroup" & return after theList
  end repeat
  put theList
end mouseUp
After you got this working, you might investigate more complex stuff like adding/removing the checkmark buttons on the fly, or what to do when the user adds too many buttons.

See also this lessons on group scrolling: http://lessons.runrev.com/s/lessons/m/4 ... the-window
There's also a basic intro to groups in the scripting conferences: http://www.runrev.com/developers/lesson ... nferences/
And maybe later on, this lesson on dynamical object positioning: http://lessons.runrev.com/s/lessons/m/4 ... is-resized
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Adrian
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 79
Joined: Wed Jul 11, 2012 5:03 pm

Re: Scrolling variable set of checkboxes

Post by Adrian » Thu Jul 12, 2012 5:40 pm

Thanks Bjoernke for the detailed reply. I'm sure I've had a play with checkboxes and they look pretty rough on iOS, but I'll have another go. Also, I presume I would need to use an iOS scroller holding the grouped checkboxes to get proper srolling, rather than a scroll bar on iOS?

I have scrollers elsewhere in my projct and I think I have got the basic hang of them. The thing I wasn't sure how to do was in script to be able to set up a bunch of checkboxes within a scroller and have it all look like native iOS. The items in the "tick list" will come from a sql database, so need to be created on the fly, as the card is opened.

Cheers,

Adrian.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Scrolling variable set of checkboxes

Post by BvG » Fri Jul 13, 2012 1:10 am

for native looks there's several commercial add-ons, mobgui, tmControls, economy-x-talk ios gui elements, etc.

you could fake it yourself by setting the icon, hiliteIcon, armedIcon, etc. look at the icons and border property palette :)
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Adrian
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 79
Joined: Wed Jul 11, 2012 5:03 pm

Re: Scrolling variable set of checkboxes

Post by Adrian » Fri Jul 13, 2012 8:00 am

OK, I'll do some more experimenting. I'm using MobGUI, but that doesn't inclide checkboxes.

Thanks again for our help.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Scrolling variable set of checkboxes

Post by BvG » Sat Jul 14, 2012 2:04 pm

That's because iOS doesn't do checkmarks. It does switch buttons:
http://mobgui.com/doc.php?docId=7
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Adrian
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 79
Joined: Wed Jul 11, 2012 5:03 pm

Re: Scrolling variable set of checkboxes

Post by Adrian » Sat Jul 14, 2012 5:31 pm

Thanks. Yes, I realised that, but wanted to emulate the Reminders app, ticking things off the list. I've pretty much achieved that using a MobGUI scroller and using script to add in checkboxes, using custom icons - thanks for the pointer.

In case anyone else comes across this post and wants more detail, I used a hidden button to contain the relevant script and used the behaviours property of th checkboxes to get them to inherit the script. The script essentially adds the selected checkbox name to a hidden field and removes it (using the nifty "filter") when de-selected. It all works really quite simply. Hurrah!

Post Reply