Main menu puzzle
Alex Tweedly
alex at tweedly.net
Sat Feb 18 08:36:13 EST 2006
Ken Apthorpe wrote:
>Thanks Alex
>
>I'll copy and paste that into my Rev tips file, so I remember it's a
>parameter name. I still do not understand how pWhich can tell that I've
>picked a menu item like Quit (or Open, or anything else).
>
>So, how does a pWhich identify what's been picked? (you see the dimensions
>of my ignorance).
>
>
>
Handlers (and functions) can have parameters - which can be named
anything you like. If it's a built-in handler, then the documentation
will tell you what the parameters are. For instance, the docs for
menuPick say
> Sent to a button when a menu item is chosen from the menu associated
> with that button.
>
> menuPick chosenItem[|submenuName],previousTab
>
> on menuPick theItem -- in a pulldown menu
> if theItem is "Close" then close the defaultStack
> else if theItem is "Quit" then quit
> end menuPick
>
As you can see, this example uses "chosenItem" rather than "pWhich" as
the name for the first parameter. Further on in the docs, it describes
these parameters as
> Parameters:
> The chosenItem is the text of the menu item the user chose. If the
> menu item is part of a submenu, the menu item text is followed by a
> vertical bar (|) and the submenu's name.
>
> The previousTab is the text of the menu item that was selected before
> the user chose a new menu item. This parameter is included only if the
> button's menuMode property is set to "tabbed".
>
So we know that the first parameter contains the text of the menu item
chosen. You can therefore use it in an "if" condition (as in the docs
example) or in a switch statement (as the menuBuilder does), or any
other you might want.
>Comment for Rev support:
>I have to wonder why I had to go to a user forum and rely on helpful others
>to provide this information. If it's a convention (ie something "everyone"
>knows, and follows) one can only wonder why it doesn't seem to appear in the
>Rev dictionary. I did a fairly thorough search, and I supposed it might be
>a parameter (among other things), so I put in parameter as a search term and
>scrolled thru the list of parameters, and failed to find it. If it is such
>a common convention, how come?
>
>
The naming convention is unofficial, and does not need to be followed.
Not everyone follows it. It would therefore be misleading for it to be
documented by Rev; as you can see, their own examples in the docs do not
follow this convention (but I recommend you do - *one* full description
of *one* convention is at
www.fourthworld.com/embassy/articles/scriptstyle.html - other people
use variations of it.
(In fact, there is lots of good stuff at
www.fourthworld.com/resources/index.html )
>Answer: Everybody knows this...
>Reply: No, they don't.... but if you want Rev to be scripting for the rest
>of us, you'll have to make it a bit easier to find it out.
>
>Thanks Alex. As you can see, I have another agenda going here but I
>appreciate all the help I can get. I need lots.
>
>
Keep asking.
btw - I looked back at the Scripting Conference for Menus, and there is
a description of building "main menus" in there - but it's under the
title "Menu Bars", so you may not have seen it when you looked. It
includes an outline script - but it's basically only the same as the
outline created by menu, so you would probably still have run into the
same issue with the proper format of the switch structure.
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.11/264 - Release Date: 17/02/2006
More information about the use-livecode
mailing list