I'm having a weird issue where I click away from my window. It resigns main and key. Then I click back to it and the view that was clicked on does not respond to the mouse click. But the second click does cause the view to respond. As if during the first click, the window wasn't key and the click caused it to become key and was able to handle the second click.
I subclassed NSApplication
and intercepted sendEvent:
to see if my application was getting the events during the first click event and indeed it was. Furthermore, I dumped the responder chain and saw that indeed my view was in the chain, but the window was not key until the second click. I also noticed that when I receive the first click event, the application isn't even active. How is this possible? Isn't an application supposed to become active when it receives a mouse event? Chicken/egg...
Any thoughts/sugggestions?
Update: After reading through the docs I found this:
Mouse-down events are sent when a user presses the mouse button while the cursor is over a view object. If the window containing the view is not the key window, the window becomes the key window and discards the mouse-down event. However, a view can circumvent this default behavior by overriding the acceptsFirstMouse: method of NSView to return YES.
So that appears to be what is happening. However, I tried overriding acceptsFirstMouse:
and acceptsFirstResponder
but to no avail. My views are still not "accepting first mouse".
Thanks!
[super something];
somewhere ? – user971401NSApplication
myself, so it was just a guess. Yes the event goes through the responder chain, passinghitTest:
for each, but I'm sure you already tested that your view objects recieved the events inmouseDown:
; at least by clicking almost anywhere... – user971401