PDA

View Full Version : Check NSOpenPanel selection before openSheetDidEnd




lopoz
May 24, 2009, 03:23 AM
Hello,

I have an image viewer that opens directories and loads the pictures contained in them. What I'd like to do is check the contents of the directory for the presence of pictures, BEFORE the openSheetDidEnd selector is called, show the user an alert if the directory doesn't contain any images and have the user pick another directory.

How can I achieve this?

Thanks in advance for any advice!



kainjow
May 24, 2009, 10:46 PM
Setup a delegate on the open panel and implement panel:isValidFilename: - this will get called when the Open button is clicked. You can then return NO to force the user to select another file/folder.

lopoz
May 25, 2009, 04:41 AM
Setup a delegate on the open panel and implement panel:isValidFilename: - this will get called when the Open button is clicked. You can then return NO to force the user to select another file/folder.

Thanks! I'll try that immediately!

And there I was trying to subclass NSOpenPanel.. It wasn't working out :p