[comp.sys.mac] Calculating a new Menu on the spot.

larryh@tekgvs.TEK.COM (Larry Hutchinson) (09/03/87)

What is the proper way to calculate and install a revised menu when the
user presses the mouse button in a specific menu title in the menu bar?

I have one menu that changes frequently and would prefer to update the
menu only when the user clicks the title in order to avoid setting and checking
flags at multiple places in my program.  I don't want to slow down all the
menus by recalculating every time the menu bar is hit anywhere - just when
the title of this menu is hit.

At first I thought that I would install a MBarHook routine (which is called
when the menu title is hilited and the menu rect is calculated) and use the
global TheMenu which is supposed to contain the current menu id to determine
which title was hit.

Experimentation (after the program was written) determined that TheMenu
is not set until after a menu item is chosen and thus is of no use in this
application (or any other?).  Besides, it wasn't clear that it was proper
to recalculate the menu rect at this point in time anyway.

I am currently thinking of scanning the menu list to determine which title
the mouse is in or perhaps writing a cusom menu definition proc.

Actually, it may be that avoiding a few flags is not worth this much effort!


Larry Hutchinson, Tektronix, Inc. PO Box 500, MS 50-383, Beaverton, OR 97077
{ decvax,allegra }!tektronix!tekgvs!larryh