Check NSOpenPanel selection before openSheetDidEnd

Discussion in 'Mac Programming' started by lopoz, May 24, 2009.

  1. macrumors regular

    May 10, 2005

    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!
  2. Moderator emeritus


    Jun 15, 2000
    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.
  3. thread starter macrumors regular

    May 10, 2005
    Thanks! I'll try that immediately!

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

Share This Page