Option Menus

Richard Gaskin ambassador at fourthworld.com
Mon Jun 6 09:59:58 EDT 2011

Todd Geist wrote:

> I have another simple question. In HTML for example, when I set up an Option
> menu I can set both the Name and the Value of the each of the options in the
> list.  This give me a way to display one thing to the use but reference a
> different value on selection of that item.
> In Live Code I can only set one value, not two.
> This seems to me to be a rather common requirement. If I am asking users to
> select something in the menu, I want to show them something Nice but
> actually use a unique ID of some sort when they select it. So I am curious
> if the community has arrived at a common way of solving this common problem.

In LC most objects have a label property which is distinct from the 
object's name, so for those it's easy to do what you're looking for.

But in LC menu items aren't objects per se, but merely strings in the 
text property of menu buttons, so a different method is needed to 
provide a similar benefit there.

In LC 3.0 or 3.5, RunRev introduced a menu tag option for menu items - 
here's the only documentation I can find on this very useful feature:


Menu-item tagging

The menu item specification has been extended to allow a tag to be 
specified. It is now of the form:
   <label> [ '/' [ <accelerator> ] [ '|' <tag> ] ]
Note that the <tag> is optional as is the <accelerator> however, if you 
want an item with a tag but without the accelerator you need:
   <label> '/' '|' <tag>

The <tag> must only be composed of characters from the ASCII character set.

If a menu item has a <tag> then it is the tag string that is passed to 
menuPick rather than the <label>. This is useful for localization of 
menu items as you don't need to change the menuPick handler for each 
language supported.

The following tags should be used to label the standard edit menu items 
to enable them to be controlled by the system dialogs on Mac OS X (e.g. 
answer file, ask file etc.):
   undo, redo, cut, copy, paste, clear, select all, preferences

Note: You should not mix the use of tags and no tags in Unicode menus. 
Doing so will cause empty values for all unicode items without tags.


I was able to turn those up in the Engine Change Log for v3.5, but I see 
no mention of this feature in the menuPick entry in the Dictionary, so I 
submitted a request to have them added:

  Richard Gaskin
  Fourth World Media Corporation
  Ambassador at FourthWorld.com       http://www.FourthWorld.com

More information about the Use-livecode mailing list