views:

51

answers:

2

I'm trying to determine when an NSOpenPanel is closing before it actually closes. I need to do this so I can overlay another window with a screenshot of the open panel on top of it to be animated. Unfortunately, all the notifications that you seem to be able to access seem to fire AFTER the window's already been closed. This leads to a jarring stutter before you start your transition.

I've tried:
- using NSWindow delegate methods on the open panel (apparently, none of the NSWindow delegate methods work)
- monitoring panel:userEnteredFilename:confirmed: (not called)
- showing the dialog with a callback (callback happens AFTER the panel disappears)

A: 

You should register your controller as the open panel's delegate and then implement the -panel:isValidFilename: delegate method. This method will be called just before the open dialog closes.

You should return YES from the method if you just want the notification. Returning NO allows you to prevent the open dialog from being closed.

Rob Keniger
I believe that panel:isValidFilename is not called when the cancel button is clicked... Thanks for your help (i know this is late).
Martin
A: 

Another way to handle this was to look through NSOpenPanel's subviews for the Cancel button and swap yourself in as the target/action. This is what i ended up doing.

Martin