Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!rochester!ur-tut!sunybcs!rutgers!labrea!decwrl!pyramid!voder!apple!lsr
From: lsr@apple.UUCP (Larry Rosenstein)
Newsgroups: comp.sys.mac
Subject: Re: PopUp menus
Message-ID: <1340@apple.UUCP>
Date: Mon, 20-Jul-87 20:31:56 EDT
Article-I.D.: apple.1340
Posted: Mon Jul 20 20:31:56 1987
Date-Received: Wed, 22-Jul-87 04:29:24 EDT
References: <2695@crcge1.UUCP>
Reply-To: lsr@apple.UUCP (Larry Rosenstein)
Organization: Advanced Technology Group, Apple Computer
Lines: 88
Keywords: System4.1 Menus PopUp

In article <2695@crcge1.UUCP> ranson@crcge1.UUCP (D. Ranson CNET) writes:
>
>Anybody knows how to use the PopUpMenuSelect trap ($A80B) that comes
>with System4.1 ? It looks like its interface is similar to that of
>MenuSelect, except there is an extra parameter (menuID?). And how
>should InsertMenu be used for a PopUp menu?

The only documentation I have seen has been a cryptic text file I pulled
off of a file server here, and the MPW 2.0b1 interface files.  I have
gotten it to work, however, so I can pass along some info.

First the interface to the trap looks like this:

	FUNCTION PopupMenuSelect(theMenu: MenuHandle;
				 left, top, item: INTEGER): LONGINT;

The return result is the same as with MenuSelect.

The item parameter is the number of the menu item whose topLeft corner
should appear at the specified location.  The left and top parameters are
given in global coordinates.  The new menu defproc will ensure that the
popup menu is entirely on the screen.  (It will scroll the menu if necessary
to bring the selected item at the desired point.)

The menu being popped up should be installed in the same way as a
hierarchical menu.  In other words, you pass -1 as the beforeID to
InsertMenu.

The other tricky thing to watch out for is determining whether you can use
popup menus.  The information I have says to do the following:

1.	Make sure you have 128K ROMs.

2.	If you have 128K ROMs, you next have to see if the new Menu Manager
has been initialized by checking if the longword at location $B5C contains
$FFFFFFFF.  If so, then the new Menu Manager is not installed.  (According
to the memo, this is necessary because Radius patches out much of the Menu
Manager.) 

3.	Check to see if the GetItemCmd trap ($A84E) is implemented by
getting the trap address for it, and comparing that to the trap address for
the $9F trap (which is always unimplemented).  Remember that this is a
Toolbox trap (not an OS trap); see Inside Mac volume 4 for more info.  (It
seems to me that you could check for the existence of PopupMenuSelect as
well.) 

4	Check to see if you have the latest MDEF resource.  The code for
the new Menu Manager is installed by patches at boot time, and therefore
does not depend on the current System file.  Popup menus, however, require
the cooperation of the MDEF, so if someone switch launches to an old System,
the old MDEF won't work.

You can check the MDEF version by looking at the word at offset 10 (decimal)
into the MDEF resource.  If it is 10 (decimal) or greater than you have an
appropriate resource.


According to the Human Interface Note #5, popup menus should be used only
for lists of related items and not for commands.  For example, if you wanted
to set the baud rate for a port, you could allow the users to select from
among the available rates.  

The existence of a popup should be signalled by a 1-pixel drop shadow drawn
around the current value; popups should never be invisible.  There should
also be a label for the value.  

When the user clicks on the current value, you should invert the label and
popup the menu with the current selection under the mouse.  (That way if
the user immediately releases the button, nothing changes.)
PopupMenuSelect only manages the menu itself.  You are responsible for
inverting the "title" of the popup.


I believe that this information is accurate, since it seems to work for me.
I have not, however, seen this written up in a draft of Inside Macintosh
volume 5, so some of the details might be wrong.  (The memo I mentioned was
written before the new Menu Manager was finalized, so it doesn't quite
correspond with reality.)

-- 
Larry Rosenstein

Object Specialist
Apple Computer

AppleLink: Rosenstein1
UUCP:  {sun, voder, nsc, mtxinu, dual}!apple!lsr
CSNET: lsr@Apple.com