Page 1 of 1

Label of Option Menu button

Posted: Tue Feb 09, 2016 6:12 pm
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

Re: Label of Option Menu button

Posted: Tue Feb 09, 2016 6:20 pm
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

Re: Label of Option Menu button

Posted: Tue Feb 09, 2016 7:42 pm
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

Re: Label of Option Menu button

Posted: Wed Feb 10, 2016 11:33 am
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

Re: Label of Option Menu button

Posted: Wed Feb 10, 2016 12:36 pm
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

Re: Label of Option Menu button

Posted: Wed Feb 10, 2016 6:11 pm
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