Return selected item of option menu

Ken Ray kray at
Fri Nov 12 13:27:40 EST 2004

On 11/12/04 11:29 AM, "Kaveh Bazargan" <kaveh at> wrote:

> Thanks everyone. :-)
> Label was the easy answer I was looking for, and I think MenuHistory sounds
> interesting too.


You (and others) should be careful about using the label on popup buttons IF
you have code that manipulates it... for example, I have code that restricts
the width of a popup button to a certain number of pixels, and truncates the
label and adds ellipses to make sure the text doesn't get cut off.

In *this* situation, you *don't* want to get the label of the button, since
you might get the shortened version with ellipses. My suggestion would be to
always use the "selectedText" of the button. This will always give you the
full text of the item that is currently active on the button, *even* if the
label has been changed. MenuHistory only gives you the index number to the
line that is currently active.

So suppose you had a popup button with three lines of text in it:

  Test first line
  This is a really long line
  Third line of data

Using my truncation routines, if I selected the second option, the label of
the button might read "This is a really lon...". So here's the different
access methods to get the currently active line:

  put the label of btn 1
    --> This is a really lon...

  put the menuHistory of btn 1
    --> 2

  put the selectedText of btn 1
    --> This is a really long line

  put line (the menuHistory of btn 1) of btn 1
    --> This is a really long line

Hope this helps,

Ken Ray
Sons of Thunder Software
Web site:
Email: kray at

More information about the Use-livecode mailing list