Option Menus

Slava Paperno slava at lexiconbridge.com
Mon Jun 6 11:10:35 EDT 2011


I use a custom property for this purpose. For example, when I use it as a
navigation menu to go to a card that the user selects from an Options
control, my cards have their real names and also each card has a custom
property called DisplayName. Then I use this in the Options control (where
pItemName is the parameter that the control gets when selected)

  repeat with i = 1 to the number of cards in this stack
      if the DisplayName of card i of this stack is pItemName then
         set the menuHistory of me to i
         go to card (short name of card i)
         exit repeat
      end if
   end repeat

Instead of custom properties you can use an array.

I am sure there are smarter ways to do what you want as well, but this
works. 

Slava

> -----Original Message-----
> From: use-livecode-bounces at lists.runrev.com [mailto:use-livecode-
> bounces at lists.runrev.com] On Behalf Of Ken Ray
> Sent: Monday, June 06, 2011 10:08 AM
> To: How to use LiveCode
> Subject: Re: Option Menus
> 
> > 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.
> 
> It's a shame you need to use Option menus, because the pulldown/popup form
> has been extended to allow for abritrary tagging (as of 4.0 I believe).
It's the
> form:
> 
> <itemName>/<acceleratorKey>|<tag>
> 
> and if you don't want to show and <acceleratorKey>, you just omit it. So
if you
> were using a popup menu for example, you could put this into the button:
> 
> Apple/|red
> Orange/|orange
> Lemon/|yellow
> 
> and the user would only see choices for "Apple", "Orange", and "Lemon",
but if
> they picked "Apple", you would get "red" coming into your menupick handler
> instead of "Apple".
> 
> 
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list