Label of Option Menu button

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
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Label of Option Menu button

Post by francof »

hi all,
with the code below I populate the text property of the option menu "btnVitigni"

Code: Select all

set ItemDel to TAB
   repeat for each line tLine in tListaViti
      put item 2 of tLine & return after gDatiViti
   end repeat

 set the text of button "btnVitigni" to gDatiViti
but why data goes to delete the label content?
to avoid it, at the end of the code I've added this:

Code: Select all

 set the label of btn btnVitigni to "Seleziona un vitigno"
it is normal?

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

Re: Label of Option Menu button

Post by Klaus »

Buongiorno Franco,

yes, that is correct behaviour and makes the extra last step neccessary!
That's the "nature" of option buttons.

Best

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

Re: Label of Option Menu button

Post by dunbarx »

Franco.

If you simply set the text of an option button, the "label" will default to the first line of the contents. You lose any preset menuHistory. Try this: make first a regular button and then an option button. Put this into the script of the regular button:

Code: Select all

on mouseUp
     set the text of btn 2 to "XX" & return & "YY" & return & "ZZ"
         wait 30
     set the menuHistory of btn 2 to 2
     wait 30
     set the text of btn 2 to "AA" & return & "BB" & return & "CC"
end mouseUp
At the end you get "AA" as the label. So earlier, when you set the label in your handler, you also set the menuHistory. The two sort of go together.

Craig Newman
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Label of Option Menu button

Post by francof »

buongiorno Klaus, nice to meet you.
so, I've hit the nail on the head... I do not was sure to be on the right way.

Hi Craig,
I've tried your exemple.
I read with menuHistory property is possible to change the selected item in of a option menu and find which item is selected.

one doubt: when I set the label of the opt button, this line isn't in the items menu. i.e.:
label:
"select an item"
items:
AA
BB
CC

here item 1 is AA and the numbers of items are 3
is it true?

thanks all
franco
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Label of Option Menu button

Post by Klaus »

Hi Franco,
francof wrote:one doubt: when I set the label of the opt button, this line isn't in the items menu. i.e.:
label:
"select an item"
items:
AA
BB
CC

here item 1 is AA and the numbers of items are 3
is it true?
not really, the correct description would be:
AAA is LINE 1 of the text of btn "your option button" and the number
of lines of the text of that button are 3.

If that is what you mean!

In your case, where you need the "label" to be always "Select an item"
maybe you want to use a "pulldown" or "pop-up" menu button instead?
Removes the need to set the label again and again and again and... :D


Best

Klaus
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: Label of Option Menu button

Post by francof »

Hi Klaus,
Klaus wrote: not really, the correct description would be:
AAA is LINE 1 of the text of btn "your option button" and the number
of lines of the text of that button are 3.

If that is what you mean!
Klaus
yes it is, not item but line.

Klaus wrote: In your case, where you need the "label" to be always "Select an item"
maybe you want to use a "pulldown" or "pop-up" menu button instead?
Removes the need to set the label again and again and again and... :D


Best

Klaus
good idea, this is like the "Egg of Columbus" I will do a try.

franco
Post Reply