• 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: How a window was closed?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How a window was closed?


  • Subject: Re: How a window was closed?
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 3 Mar 2010 08:43:38 -0800

On Mar 3, 2010, at 7:20 AM, Eric Gorr wrote:

>> Otherwise, you can make your class implement the NSWindow delegate method -windowShouldClose:, which will also be called when the user tries to close the window.
>
> This method is called after I press the close (red) button. My only concern here is that the method does not necessarily lend itself to be exclusively called at this time and it would be a problem if it was ever called if the window was being closed for any other reason.

No offense, but why do you need to distinguish between these? It might be a bad user interface design — for example, have you considered that some disabled users have trouble with precise gestures and use keyboard equivalents whenever possible?

I can assure you that -windowShouldClose: is only called in response to direct user interaction, and is often used to put up a confirmation sheet.

> So, how certain is it that it will _only_ be called if the user presses the close (red) button?

It's also called if the user chooses the Close menu command or presses Cmd-W.

> With the old toolbox, one would receive a mouse down event and be able to determine what window and what part of the window it belonged to. One of these parts was "inGoAway". I just need the same information with the same reliability.

You could examine [NSApp currentEvent] and see if it's a mouse event, if you really need to know.

—Jens_______________________________________________

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: How a window was closed?
      • From: Eric Gorr <email@hidden>
References: 
 >How a window was closed? (From: Eric Gorr <email@hidden>)
 >Re: How a window was closed? (From: Jens Alfke <email@hidden>)
 >Re: How a window was closed? (From: Eric Gorr <email@hidden>)

  • Prev by Date: Re: Trying to achieve aperture PopUp buttons
  • Next by Date: Re: running javascript from obj-C
  • Previous by thread: Re: How a window was closed?
  • Next by thread: Re: How a window was closed?
  • Index(es):
    • Date
    • Thread