• 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: Eric Gorr <email@hidden>
  • Date: Wed, 3 Mar 2010 10:38:56 -0500

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

>
> On Mar 2, 2010, at 6:42 PM, Jens Alfke wrote:
>
>>
>> On Mar 2, 2010, at 3:32 PM, Eric Gorr wrote:
>>
>>> Is there any way to determine how a window was closed?
>>> I need to base what I do on whether or not a window will be closed by the user pressing the close (red) button or some other way.
>>
>> If you have an NSWindow subclass, you can override -performClose:, which is called when the user takes action to close the window.
>
> I tried this, but performClose: was not called after I pressed the close (red) button. The intent of this method seems to be to simulate the click, not respond to it.
>
>> 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. So, how certain is it that it will _only_ be called if the user presses the close (red) button?
>
> 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.
>
> Now, I suppose I could attach a carbon event handler to my window and ask for kEventClassWindow / kEventWindowClickCloseRgn events, but I was hoping to avoid this and am surprised that there isn't something as clear in Cocoa.

Looks like I spoke to soon and should have tried the carbon event handler first. This does not work - the event is not generated.

_______________________________________________

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

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: NSXMLDocument and threads
  • Next by Date: Re: How a window was closed?
  • Previous by thread: Re: How a window was closed?
  • Next by thread: Re: How a window was closed?
  • Index(es):
    • Date
    • Thread