NSMenuItem Custom View Not Responding to mouseDown Single Clicks

Originator:np101137
Number:rdar://7128269 Date Originated:07-Aug-2009 09:43 PM
Status:Open Resolved:Yes
Product:Mac OS X Product Version:10.5.7/9J61
Classification:Other Bug Reproducible:Always
 
Summary:
Views that implement mouseDown and are the views of an NSMenuItem (setView:), don't receive mouseDown except on a multiple click.  mouseDown is not called on single click.

Steps to Reproduce:
1.  Make an NSStatusItem in the systemStatusBar.  In my case, mine used a custom view that responded to mouseDown to toggle the menu with popUpStatusItemMenu:.

2.  Make an NSMenu, with an NSMenuItem and set the item's view to a NSView subclass.

3.  In that NSView subclass (the one for the NSMenuItem), implement mouseDown: (I just made an NSLog to check).

4.  Build and Go --> Click the view in the menu item of the menu, you'll notice that it doesn't respond to single clicks, however, it responds to multiple (double, for example) clicks.

Expected Results:
mouseDown will be called on all clicks, regardless of click count.

Actual Results:
mouseDown is only called on multiple clicks in a row (double clicks, etc).

Regression:
My Macbook Pro (2.2Ghz) is running Leopard, and it seems it was able to be reproduced frequently.  On occasion it would respond on the single click, but after closing and reopening the menu, it would no longer do that.

Comments

I had a similar problem only worse

On Snow Leopard, I can't seem to get any clicks, double or otherwise. I am working on a horrendously complex and irritating fix with nextEventMatchingMask. It is a mess.

Please see my summary of the situation at Stack Overflow:

http://stackoverflow.com/questions/1395556/custom-nsview-in-nsmenuitem-not-receiving-mouse-events

I recognized, as did the author of the work-around above, that it is important for the window to become key. Problem is, even though the window reports YES to canBecomeKey--it actually won't become key when you ask it to do so.

By dennis.hartiganoconnor at Sept. 9, 2009, 5:20 p.m. (reply...)

I can't get this work-around to function on Snow Leopard

This "work-around" didn't help me on Snow Leopard.

By dennis.hartiganoconnor at Sept. 9, 2009, 5:18 p.m. (reply...)

Work Around

Work around detailed here: http://firen.tumblr.com/post/167890659/nsmenuitem-custom-view-annoyance


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!