On Sep 11, 2010, at 9:42 AM, Richard Somers <rsomers.li...@infowest.com> wrote:

> 
> 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.

On further review, this makes sense to me. Holding down the Control key is an 
explicit signal to the system that you wish to interact with the application as 
if it were frontmost. -acceptsFirstMouse: is useful as a guard against 
misclicks, not against intentional use of the Command key.

That said, you probably don't want to lose data because the user misclicked 
while trying to Command-click in a table view. So I understand why you want to 
disable this control, and why -acceptsFirstMouse: is insufficient.

> 
>> 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 think this might just be how they draw. They listen for key/main/frontmost 
notifications and change color accordingly.

> 
> 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;

You probably want -isMainWindow instead. Otherwise panels that become key (like 
the Special Characters palette) will make it impossible to interact with your 
control.

--Kyle Sluder_______________________________________________

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