• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Inactive Window Receives Mouse Events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inactive Window Receives Mouse Events


  • Subject: Re: Inactive Window Receives Mouse Events
  • From: Kyle Sluder <email@hidden>
  • Date: Sat, 11 Sep 2010 10:07:47 -0700

On Sep 11, 2010, at 9:42 AM, Richard Somers <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Inactive Window Receives Mouse Events
      • From: Richard Somers <email@hidden>
References: 
 >Inactive Window Receives Mouse Events (From: Richard Somers <email@hidden>)
 >Re: Inactive Window Receives Mouse Events (From: Kyle Sluder <email@hidden>)
 >Re: Inactive Window Receives Mouse Events (From: Richard Somers <email@hidden>)

  • Prev by Date: Re: [iOS] Sub Class MKPlacemark - Identifying each Placemark
  • Next by Date: Re: Inactive Window Receives Mouse Events
  • Previous by thread: Re: Inactive Window Receives Mouse Events
  • Next by thread: Re: Inactive Window Receives Mouse Events
  • Index(es):
    • Date
    • Thread