• 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: Trapping the close click?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trapping the close click?


  • Subject: Re: Trapping the close click?
  • From: Dustin Voss <email@hidden>
  • Date: Fri, 30 May 2003 00:38:57 -0700

On Wednesday, May 28, 2003, at 07:46 AM, Ryan Stevens wrote:

On Wednesday, May 28, 2003, at 06:27 AM, Matthew Weinstein wrote:

Does anyone out there know if there is a way to "trap" the close click, i.e., have it send a message to something other than performClose?


This should work...

id closeButton = [yourWindow standardWindowButton:NSWindowCloseButton ];
[closeButton setAction:@selector(yourActionMethod:)];
[closeButton setTarget:self];

Standard warning: Be careful not to "break" it. Everyone expects that clicking the close button will close the window. ;-)

That's assuming you weren't really looking for NSWindowWillCloseNotification.

I think there's an undocumented "_close:" method implemented by NSWindow. Perhaps you could write an NSResponder sub-class to catch it and do something. You'd instantiate the responder and insert it into the responder chain above the window's content view.

But I like Ryan's solution better.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Trapping the close click? (From: Ryan Stevens <email@hidden>)

  • Prev by Date: Re: Need Help with Obj-C -> Java bridge method calls with multiple arguments
  • Next by Date: Re: simple float/double question
  • Previous by thread: Re: Trapping the close click?
  • Next by thread: Forwarding to mimic multiple inheritance
  • Index(es):
    • Date
    • Thread