Getting the line number from "on menupick"

Richard Miller wow at together.net
Fri Nov 13 05:31:00 EST 2009


Jan,

Thanks! Works perfectly. Exactly what I was looking for.

Richard Miller



Jan Schenkel wrote:
> Well, rev 3.5 introduced something called menu 'tagging' - here's a copy from the IDE change log included with rev 3.5
>
> ===
>
> 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.
>
> ===
>
> Even though it sounds like it's only for "menubar" menus, tagging works for any type of menu. So you can use this knowledge to make the text:
>
> My Silly Name That I Reuse For Everything/|1
> My Subgroup/|2
> <tab>My Silly Name That I Reuse For Everything/|3
> My Silly Name That I Reuse For Everything/|4
>
> And then your menupick will automagically get the 'tag' value as the line number; of course with sub-menus, you get a pipe-delimited list of tags, with the entire hierarchy.
>
> So assuming that you change the text of your menu to the above style, your script could be something like:
> ##
> on menuPick pItemTag
>   set the itemDelimiter to "|"
>   put the last item of pItemTag into tLineNumber
>   ...
> end menuPick
> ##
>
> Menu tags also greatly simplify multilingual apps, as we can now just tag the items in our preferred language (or english, for consistency with the MacOSX presets) and work with the tag in our scripts.
>
> Jan Schenkel
> =====
> Quartam Reports & PDF Library for Revolution
> <http://www.quartam.com>
>
> =====
> "As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)
>
>
> --- On Thu, 11/12/09, Richard Miller <wow at together.net> wrote:
>   
>> I have a pulldown button with data in
>> it that makes it act as a cascading menu. When the user
>> selects an item, I need to know which item has been
>> selected... not just the text, but the line number or some
>> other data that would let me know which item was selected,
>> so I can get more info about that item from an associated
>> database.
>>
>> The problem I have is that many of the lines in the
>> cascading menu appear identical by name, though they are not
>> the same item. It's just that the label assigned by the user
>> is the same (they represent names of videos.... and the user
>> can name them any way they want, even though the actual file
>> names are different).
>>
>> Any given line in the menu may be 5-10 words long... which
>> as it is, makes the menu rather wide. I could add an
>> identifying tag after each line [ such as (1), (2), etc.],
>> but that's not very elegant (but perhaps the only
>> solution).
>>
>> I tried using:
>>
>> put the selectedlines of me
>> put the menuhistory of me
>>
>> But these don't seem to work with cascading menus.
>>
>> Any tricks here that would give me the line number
>> selected?
>>
>> Thanks.
>> Richard Miller
>>
>>     
>
>
>       
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>   




More information about the use-livecode mailing list