[comp.sys.mac.programmer] Hierarchial Menus with ResEdit 2.1

shores@fergvax.unl.edu (Shores) (01/03/91)

I am writing an application whose menus are to be put up using the very
handy MBAR/MENU combo.  All I had to do before is call GetNewMBar(),
SetMenuBar(), DrawMenuBar() and my entire menu would be drawn.  But my
menus are starting to go off the side of my puny MacPlus screen so I
wanted to reorganize my menubar to use some hierarchial menus.  How do
you use the nifty ResEdit menu editor to add hierarchial menus?  The
editor allows me to specify an item to have a submenu, and then it asks
for the rsrc ID of a MENU.  I can put in a valid MENU id, but when my
application runs, the menu item has the familiar filled-triangle but
when I select the item, no submenu pops up as it should.  I have used
hierarchial menus before using the hard-coded method and I do not want
to have to code in a zillion lines if all I have to do is use ResEdit
and the 4 lines or so it takes to draw the menu bar quick and
painlessly.



% t-o-m  s-h-o-r-e-s

"It's fallen and I can't get it up" --That old lady's husband

oster@well.sf.ca.us (David Phillip Oster) (01/10/91)

According to IM V 4: 
SetMenuBar(GetNewMBar( id ));
will read in, initialize, and put up an entire menu bar.
But, to get hierarchical menus to work, you need to individually

	InsertMenu(GetMenu( id), -1);

(This is all from memory, so double check in the book.)
The MBAR resource doesn't know about this second part of the process.
You might consider using a second MBAR resource, and writing your own
	GetNewHierarchicalMBar( id )
that runs down the resource getting and inserting menus.

If you are going to be really picky, Menu Manager wants you to insert the
menus when they are appicable, and delete them when they become inapplicable.
This is more an issue for popup menus that are assoicated with particular
windows, but just thought I'd mention it.
-- 
-- David Phillip Oster - At least the government doesn't make death worse.
-- oster@well.sf.ca.us = {backbone}!well!oster