Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!spam!lippin From: lippin@spam.berkeley.edu (The Apathist) Newsgroups: comp.sys.mac.programmer Subject: Re: Simulating a Menu Bar with Pop-Up Menus Message-ID: <1989Nov28.053644.28100@agate.berkeley.edu> Date: 28 Nov 89 05:36:44 GMT References: <9095@hoptoad.uucp> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: lippin@math.berkeley.edu Organization: Authorized Service, Incorporated Lines: 45 I don't think there's a good way to do this; Apple either doesn't want it to be easy or is just being lazy. But I've also hacked a menu bar with PopupMenuSelect; I don't know that my way is any better than Tim's, but here are the differences anyway: First, I don't think that calling the MDEFs directly should be overlooked as a possibility. It has the advantage of being less of a hack. On the other hand, it is difficult and it raises some compatibility questions (future MDEFs; drawing into the desktop). But I didn't use this approach; instead, I put a hack into my MDEF. I pass it an address using a high-numbered message, up where they've been reserved for applications. The address lets me communicate back and forth. Before going into PopupMenuSelect, I tell it where the menu bar is, and where the menu's title is. If the MDEF finds the mouse in the menu bar, but not in the title area and the mouse is StillDown(), it posts a fake mouse-up-mouse-down, and sets a flag indicating the fakeness. PopupMenuSelect senses this, and returns to the caller, which then grabs the mouse-down with GetNextEvent if it was faking, and goes back to tracking the menu bar. (The mouse down may not be necessary, but I prefer to post mouse events in pairs, so that the event queue will have less chance of getting out of sync with the mouse button.) Now, using a hacked MDEF instead of a MenuHook is a dubious advantage; it won't suffer when low memory globals go away, but if MDEF 0 changes in the future, my menus won't. This is fine for me -- these menus are nonstandard anyway, but it's a point that should be considered. I like posting events better than patching Button, but it's a close call. BTW, the patch Tim describes may not be a tail patch by a strict definition, but it suffers from the tail patch problem -- it blocks come-from patches. On the other hand, it blocks them only during PopupMenuSelect, and only there on rare occasions. Finally, I agree that longjumping out of a trap is a very bad idea (although my code does do it in some emergencies). It'll get you back to your application ok, but it may leave some global resources (the screen in this example) in an inconsistent state. --Tom Lippincott lippin@math.berkeley.edu "Ask a fish head anything you want to. It won't answer you; they can't talk." --"Fish Heads"