pos / neg on a button/checkbox

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bdtrauma
Posts: 34
Joined: Fri Dec 24, 2010 11:37 pm

pos / neg on a button/checkbox

Post by bdtrauma » Fri Jan 21, 2011 12:50 pm

Throwing this out there... my program requires the possibility of a positive or neg response to a checkbox. For example if I ask my patient if they have had shortness of breath I want to have a 'positive' indication or a 'negative' indication if they deny it. Just leaving a checkbox unchecked doesn't let me know if the question was actually asked. I'm looking at all the elements (checkbox / radiobuttons / menus ) and I'm trying to figure out how to most efficiently showing this on the screen as well as letting my users easily create the answer to their questions. Putting a neg and pos checkbox for each item will use a lot of space as well, but right now that's all I've come up with. Any ideas will be appreciated.

Bert

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

Re: pos / neg on a button/checkbox

Post by Mark » Sat Jan 22, 2011 2:51 am

Hi Bert,

Use pictures (icons) instead of a checkbox button.

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

bdtrauma
Posts: 34
Joined: Fri Dec 24, 2010 11:37 pm

Re: pos / neg on a button/checkbox

Post by bdtrauma » Sat Jan 22, 2011 3:47 am

Thanks Mark,

I alread do use pics to that the checkboxes look better than the ones LC has. I have been playing with this little script for the checkbox:

on mouseDoubleUp
set the visited of me to true
end mouseDoubleUp

on mouseUp
set the visited of me to false
end mouseUp

I use the visited icon pic as my negative response. It seems to work o.k. I've set the doubleclickinterval to 250 to see if it will pic up the double tap on the iPad a little better. I'm going to test it out in real life tonight at work. I basically am trying to figure a way to cycle through three icon pics for the checkbox.

Bert

bdtrauma
Posts: 34
Joined: Fri Dec 24, 2010 11:37 pm

Re: pos / neg on a button/checkbox

Post by bdtrauma » Mon Jan 24, 2011 5:42 am

well i've been struggling to make this work consistently. I thought the mousedoubleUp was the way to go using the visited but the visited fires off even when I don't want it to.

I am struggling to find a place to show the third icon (pic of red checked box connotating a neg response) but the visited , armed, and disabled just don't seem to work.

Is it possible to make a custom property for a button that is an icon and can be shown / hidden ?

Bert

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: pos / neg on a button/checkbox

Post by Klaus » Mon Jan 24, 2011 11:07 am

Hi Bert,

a "mousedoubleup" will also and always trigger a "mouseup" first!
So you need to think of another strategy, I'm afraid.


Best

Klaus

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: pos / neg on a button/checkbox

Post by bn » Mon Jan 24, 2011 1:35 pm

Bert,

if I understand you correctly you want 3 states of the button to be indicated. The untouched state, the yes and the no state.

The trick is to group the radio buttons, then only one radio button in each group can be hilited at a time.

I append a little stack that uses 2 radio buttons in a group. Initially the hilite of the 2 buttons false and the button is gray (image as icon), once you hit yes or no the yes button will be red or the no button will be blue.
If the user changes his mind he can always choose the other option whereby the non-hilited button reverts to gray. The user can not however unhilite both radio buttons. This is the feedback that the user has indeed made a choice.
You can set the hilite of both buttons to false by script to present the user the default state.

Of course you could also conceive a slider control which has an initial middle position and once the user touches it it is either in a right position or a left position. Thus inidicating the untouched/yes/no states.
You would have to script and design this object yourself so I figured the radio buttons would be the easiest way.

kind regards

Bernd
Attachments
radioButtns.livecode.zip
(14.81 KiB) Downloaded 348 times

logon68
Posts: 1
Joined: Thu Feb 03, 2011 8:35 am
Contact:

Re: pos / neg on a button/checkbox

Post by logon68 » Thu Feb 03, 2011 8:40 am

thanks Mark

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

Re: pos / neg on a button/checkbox

Post by BvG » Thu Feb 03, 2011 2:37 pm

generally, if you want more then a on/off state from the user, all UI recommendations point to radio buttons.
Various teststacks and stuff:
http://bjoernke.com

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

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: pos / neg on a button/checkbox

Post by sylvanr » Fri Feb 04, 2011 9:27 pm

Hey Bernd,
While waiting to see if Apple is going to approve my app, I'm starting to think about my next app. I have already played around a little with radio buttons and checkboxes but decided not to use them in the first app as they seemed like an additional complication I didn't need or want for just trying to create a basic app. One reason they seemed problematic is that when they were saved as a background, the state they were in was shared by every card. If the button was in a hilite state on one card, it would be in a hilite state for every card. That doesn't work for a database in which the hilite state needs to be different for every card? I downloaded your radiobuttons.livecode.zip to see if it was the same with your buttons as what I had experienced previously with my buttons. I selected everything and grouped everything as a background and then added a new card. I clicked one of the buttons and then went to the next card to see if the hilate state was the same on that card and it was. Is there a way to have the hilite state separate on each card in a stack and save the state of the button on each individual card?? What am I missing here???

Thanks, always.

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

Re: pos / neg on a button/checkbox

Post by BvG » Sat Feb 05, 2011 1:25 am

set the sharedHilite of button "checkbox" to false
Various teststacks and stuff:
http://bjoernke.com

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

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: pos / neg on a button/checkbox

Post by sylvanr » Sun Feb 06, 2011 10:01 pm

Thanks, BvG. Deselecting "shared hilite" solves the problem for the standard radio buttons and checkboxes. For some reason, it does not seem to solve the problem for radio buttons with custom icons such as in Bernd's example radiobuttons stack? Since I will be using my buttons in an iPhone app, I may want to use custom icons for the buttons. Is there a way to have the hilite state of those different for every card like the standard buttons? Thanks!

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

Re: pos / neg on a button/checkbox

Post by BvG » Mon Feb 07, 2011 7:40 am

Obviously, because it's hand crafted, you'll need to script the whole behaviour of your custom control yourself. so if you place them on different cards, and want them to be different on each card, you need to also script them to have different behaviour for each card. easiest would be to store the value in the card, and on preOpenCard, set the state to whatever you stored.
Various teststacks and stuff:
http://bjoernke.com

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

sylvanr
Posts: 80
Joined: Wed Nov 24, 2010 10:38 am

Re: pos / neg on a button/checkbox

Post by sylvanr » Mon Feb 07, 2011 8:50 pm

Obviously??

Thanks.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: pos / neg on a button/checkbox

Post by bn » Mon Feb 07, 2011 10:19 pm

Hi Sylvan,

I did not test the radiobuttons I posted if they would work in a group with backgroundbehaviour. As you pointed out it does not work. I consider this a bug.

If this is not supposed to work with custom icons then

a why does it work if the group is not a background group
b why is it not documented that you are not supposed to use custom icons in radiobuttons in background groups.

I reported this as bug #9382 to the quality control center. If you have access to the quality control center you can look at it.

A workaround for now would be to not set the background behavior of the radio group and copy the group on each new card.

Code: Select all

on newcard
   lock screen
   copy grp "rBtns" of card 1 to this card
end newcard
@BvG What do you mean hand-crafted? I did not knit it... :)

kind regards

Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: pos / neg on a button/checkbox

Post by bn » Tue Feb 08, 2011 1:37 pm

Hi Sylvan,

the Edinburgh team has already answered. They are so fast that they scare me...

#9382

They consider that grouped radio buttons with custom icons should work in background groups and try to fix it for the next version of LIvecode.

Kind regards

Bernd

Post Reply