[comp.sys.mac.programmer] Why is InsertMenu called with every click in the menubar??

mystone@sol.engin.umich.edu (Dean Yu) (02/25/89)

  This may sound like a totally useless question, and I'm probably overlooking
something obvious in the process, but why is InsertMenu being called whenever
there's a mouse down in the menubar?  This is being done by the system,
not by the application.  If there's an item in the menubar, shouldn't it
have been placed in the menu list by the application already?  It just seems
kinda pointless to me...

______________________________________________________________________________
Dean Yu                            |  E-mail:    mystone@caen.engin.umich.edu
University of Michigan             |  Real-mail: Dean Yu
Computer Aided Engineering Network |             2413 Kelsey House
===================================|             600 E Madison
"These are MY opinions." (My       |             Ann Arbor, MI 48109
 employer doesn't want them.       |==========================================
 Actually, they don't really care  | 
 what I think.  But President      |   This space intentionally left blank.  
 Duderstadt does...)               | 
------------------------------------------------------------------------------  

bob@accuvax.nwu.edu (Bob Hablutzel) (02/25/89)

>   This may sound like a totally useless question, and I'm probably overlooking
> something obvious in the process, but why is InsertMenu being called whenever
> there's a mouse down in the menubar?  This is being done by the system,
> not by the application.  If there's an item in the menubar, shouldn't it
> have been placed in the menu list by the application already?  It just seems
> kinda pointless to me...

Sounds pointless to me, too. And I just tried to duplicate it without success.
Sounds to me like it might me an INIT you're running going nuts. IMHO.


Bob Hablutzel	Wildwood Software	BOB@NUACC.ACNS.NWU.EDU

keith@Apple.COM (Keith Rollin) (02/26/89)

In article <41adbdb2.a590@mag.engin.umich.edu> mystone@sol.engin.umich.edu (Dean Yu) writes:
>
>  This may sound like a totally useless question, and I'm probably overlooking
>something obvious in the process, but why is InsertMenu being called whenever
>there's a mouse down in the menubar?  This is being done by the system,
>not by the application.  If there's an item in the menubar, shouldn't it
>have been placed in the menu list by the application already?  It just seems
>kinda pointless to me...
>
It doesn't have to be anything ominous. It could simply be that the application
you were using was resetting it menus all the time. For instance, one way that
applications can set up a 'Windows' menu is to scan the window list when the
user clicks on that menu, and create the appropriate menu items then. Another
thing that could be happening is that the application is inserting hierarchical
menus only when it needs them (ie, when you click on the menu).

I tried reproducing your situation, but was unable to. I set up TMON to break
when _InsertMenu was called. I then ran 3 applications (MPW, AppleLink, and
SmartCom). None of these applications broke when I clicked on the menu. 

Finally, how do you know that it is the system that is calling _InsertMenu? Did you write the application, so that you know what is going on? If so, then the 
source of the call may be an INIT or something. After setting up TMON, I also 
called up OnCue. Sure enough, my Mac broke into TMON 3 times: once for the 
main menu, and twice for the 2 hierarchicals I had in it.

------------------------------------------------------------------------------

Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

mystone@sol.engin.umich.edu (Dean Yu) (02/26/89)

In article <26389@apple.Apple.COM> keith@Apple.COM (Keith Rollin) writes:
  (Stuff that I said...)

>It doesn't have to be anything ominous. It could simply be that the application
>you were using was resetting it menus all the time. For instance, one way that
>applications can set up a 'Windows' menu is to scan the window list when the
>user clicks on that menu, and create the appropriate menu items then. Another
>thing that could be happening is that the application is inserting hierarchical
>menus only when it needs them (ie, when you click on the menu).

  It wasn't the application.  It was the system calling InsertMenu.
>
>I tried reproducing your situation, but was unable to. I set up TMON to break
>when _InsertMenu was called. I then ran 3 applications (MPW, AppleLink, and
>SmartCom). None of these applications broke when I clicked on the menu. 

  I tried it with an A-trap break in MacsBug, and those weren't catching
either.  Read on!

>Finally, how do you know that it is the system that is calling _InsertMenu? Did you write the application, so that you know what is going on? If so, then the 
>source of the call may be an INIT or something. After setting up TMON, I also 
>called up OnCue. Sure enough, my Mac broke into TMON 3 times: once for the 
>main menu, and twice for the 2 hierarchicals I had in it.
>
   I admit it.  I was patching InsertMenu.  I had placed a call to SysBeep
in my patch to make sure my routine was getting called.  (This is the first
time I've used Get/Set TrapAddress, so I wanted to make sure I was doing it
right.)  SO my routine was getting called, and it beeped every time I clicked
in the menubar.  Let me ammend that statement about the ATB's.  At first, I
had set an ATB for only application calls to the trap.  MacsBug didn't break
in.  I reset it to catch all calls to the trap, and it broke.  That's why I
think the system is calling InsertMenu.  Although I admit it might be an
INIT.

______________________________________________________________________________
Dean Yu                            |  E-mail:    mystone@caen.engin.umich.edu
University of Michigan             |  Real-mail: Dean Yu
Computer Aided Engineering Network |             2413 Kelsey House
===================================|             600 E Madison
"These are MY opinions." (My       |             Ann Arbor, MI 48109
 employer doesn't want them.       |==========================================
 Actually, they don't really care  | 
 what I think.  But President      |   This space intentionally left blank.  
 Duderstadt does...)               | 
------------------------------------------------------------------------------  

mystone@sol.engin.umich.edu (Dean Yu) (02/26/89)

  When I posted the original article last night, I had thought for a bit
before I posted it whether it was really the system calling InsertMenu, or
did I actually have an init that did it.  I couldn't think of one last night.
After reading Keith's article, I thought about it again, and I looked closer.
Guess what?  I had the Menu Extender init installed (I wondered how that got
in my System Folder?) and that was doing it.
  My apologies to the net for wasting bandwidth.  (I DID say in my original
posting that I was probably overlooking something obvious... :)  )

______________________________________________________________________________
Dean Yu                            |  E-mail:    mystone@caen.engin.umich.edu
University of Michigan             |  Real-mail: Dean Yu
Computer Aided Engineering Network |             2413 Kelsey House
===================================|             600 E Madison
"These are MY opinions." (My       |             Ann Arbor, MI 48109
 employer doesn't want them.       |==========================================
 Actually, they don't really care  | 
 what I think.  But President      |   This space intentionally left blank.  
 Duderstadt does...)               | 
------------------------------------------------------------------------------