Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!well!svc From: svc@well.UUCP (Leonard Rosenthol) Newsgroups: comp.sys.mac.programmer Subject: Re: Simulating a Menu Bar with Pop-Up Menus Summary: Two ways to do it... Message-ID: <14747@well.UUCP> Date: 28 Nov 89 19:27:27 GMT References: <9095@hoptoad.uucp> Reply-To: svc@well.UUCP (Leonard Rosenthol) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 51 In article <9095@hoptoad.uucp> tim@hoptoad.uucp (Tim Maroney) writes: >[Menu Bars in Windows discussion] >All well and good. But there is one problem with this -- the raw OS >doesn't give you what you need to implement this behavior. It seems as >if it would be easy to implement with PopUpMenuSelect, and it is, but I >have not been able to do it without a trap patch. It's within the >guidelines as much as any trap patch can be, but it still worries me >and I'd like to do without it if possible. I wrote all the code to do >this in the last 24 hours, so I may be overlooking something that will >hit me tomorrow, but I'd appreciate advice from the net. > >[All about Tim's Patch] > >This all works great, and it's not as hard as it sounds. But it really >irks me that I have to patch Button this way. I've never had to use >that particular devious strategy, an application-specific trap patch, >before. It's better than calling the menu definition procedures >myself, and it works, but that's about the most I can say for it. Does >anyone have a cleaner idea for how to implement a document window menu >bar? Also, does anyone see a way that this could fail, as long as >PopUpMenuSelect continues to call WaitMouseUp, and WaitMouseUp >continues to call Button before checking for a mouse-up event? > I've done menuBars in windows before, and although it does pose problems of it's own, I choose to use the 'Calling the MDEF' method. My reasoning behind this was that I was basically rewriting MenuSelect and that since MenuSelect was doing it, so could I! I've had no problem with it so far, and I doubt that it will die anytime soon (as changing the calling conventions for MDEFs would be a BAD MOVE on Apple's part as the world would break..). There was an article in MacTutor about doing this a while back, where the author actually implemeted a complete set of 'wMenuBar' tools for doing this and that could be easily moved from application to application. (ie nice and generic.) I have not look at it since it came out, but he also used the 'call the MDEF' method (though also did some interesting things as well ;-) There is one other way to do window menuBars that I have seen done, though not tried it myself, and that is to write your own MDEFs!! Just like a TearOff Menu may post an event when it gets torn off, your MDEF can post events to tell you that t he mouse has moved out of the title area and that you now need to select the next one over (and you can either send separate msgs for right vs. left or calc it yourself). Although it requires writing your own MDEF, this may be the most compatible way to go since you simply call PopUpMenuSelect as you would anyway, and there is no traps patchs and no direct calls to defProcs. -- +--------------------------------------------------+ Leonard Rosenthol | GEnie : MACgician Lazerware, inc. | MacNet: MACgician UUCP: svc@well.UUCP | ALink : D0025