On Sep 11, 2010, at 12:53 AM, Kyle Sluder wrote:

You want -acceptsFirstMouse:.

When my custom view 'acceptsFirstMouse:' returns YES this is what happens with an inactive window. A mouse click activates the window and a mouse down event is sent to the view. With command key held down, a mouse click does not activate the window and a mouse down event is still sent to the view.

On Sep 11, 2010, at 1:06 AM, Quincey Morris wrote:

I think you're slightly mis-describing the behavior. What you're seeing is actually (AFAIK) the interaction of 2 separate behaviors. First, any mouse-down event on an inactive window doesn't bring it to the front if the Command key is down too. Second, most standard controls return YES from 'acceptsFirstMouse:', which means that they respond to mouse-down events when their window is not frontmost. Put those 2 things together and you get the behavior you describe.

When the command key is held down, all mouse events are sent to the custom view in the inactive window including the first mouse down event. It does not matter if the return value from 'acceptsFirstMouse:' is YES or NO, the behavior is the same.

Are you talking about the view itself, or standard controls (subviews) within your view? I would have expected that returning NO from 'acceptsFirstMouse:' (which is the default for NSView) would have disabled the behavior for the view outside of its subviews.

My custom view is a subclass of NSView and has no subviews. As mentioned above returning NO from 'acceptsFirstMouse:' does not disable the view from receiving mouse events when the window is inactive and the command key is held down.

Note that the behavior can vary on a case by case basis. In Mail, for example, the "Junk" toolbar button is disabled when inactive, but the "New Message" button is left enabled.

You are right. Some controls are disabled on inactive windows and can not be clicked with the command key held down. It would appear that subclasses of NSControl are disabled on inactive windows when returning NO from 'acceptsFirstMouse:' but this functionality not available for a subclass of NSView.

I just thought of a work around. Put the following code at the beginning of all mouse responder methods in the custom view.

if (![[self window] isKeyWindow]) return;

I tried it and it works. Also returning YES or NO from 'acceptsFirstMouse:' works as expected.

--Richard

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to