Option button and the label

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
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Option button and the label

Post by Mag » Tue Mar 11, 2014 1:51 pm

Hi all,

I noticed that if I change the label of an option button then the selected item I see when I open the option button is not the one that match to the label (in fact it's selected the one I choose latest).

Is there a way to update also the selected item along the label? Any help will be appreciated! :mrgreen:

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Option button and the label

Post by FourthWorld » Tue Mar 11, 2014 2:17 pm

If you set the label using the menuHistory property the control will have the behavior you're looking for.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Option button and the label

Post by Mag » Tue Mar 11, 2014 3:26 pm

Thank you Richard, another thing learned.

PS
I wonder if there is also a way to avoid that is sent the message menuPick... (I'm using the Option Button to open a window, each item corresponds to a window).

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

Re: Option button and the label

Post by Klaus » Tue Mar 11, 2014 4:17 pm

Hi Mag,

I think you can:
...
lock messages
set the menuhistory of btn ...
unlock messages
...

Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Option button and the label

Post by FourthWorld » Tue Mar 11, 2014 4:27 pm

Klaus' suggestion is a good one, and if you do it often you can wrap it in a handler like this so it's a one-liner whenever you need it:

Code: Select all

on SetOption pBtnObj, pItem
   lock messages
   set the wholematches to true
   set the menuHistory of pBtnObj to lineoffset( pItem, the text of pBtnObj)
   unlock messages
end SetOption
FWIW, I submitted a request to extend the behavior of "set the label..." this morning, and Mark Waddingham noted some interesting aspects I'd not originally considered - feel free to chime in with your own thoughts there:
http://quality.runrev.com/show_bug.cgi?id=11917
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply