Question

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)

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top