0

I have a NSPathControll set up in IB and I use this method when I set up the NSOpenPanel:

-(void)pathControl:(NSPathControl *)pathControl willDisplayOpenPanel:(NSOpenPanel *)openPanel
{
    [openPanel setDelegate:self];
    [openPanel setCanChooseDirectories:YES];
    [openPanel setCanCreateDirectories:YES];
    [openPanel setCanChooseFiles:NO];
    [openPanel setPrompt:@"Choose"];
}

I would like to know when the user clicked the OK-button (in this case the 'Choose'-button).

If I use -(void)panel:(id)sender directoryDidChange:(NSString *)path I only get notified when the user double clicked on a folder.

Any ideas?

Thanks in advance!

Mikael
  • 3,572
  • 1
  • 30
  • 43

1 Answers1

0

I solved it by using:

-(BOOL)panel:(id)sender isValidFilename:(NSString *)filename

I was looking for a "panel:(id)sender didClose" or something similar.

/M

Mikael
  • 3,572
  • 1
  • 30
  • 43
  • 1
    Apple has deprecated the non-Sandbox compatible methods that had "`didEndSelector:`" in there, and NSOpenPanel now runs in a separate thing called a ["powerbox" (i.e. somewhere between your app and the OS; and not exactly either)](https://developer.apple.com/library/mac/documentation/security/conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW17), so Apple doesn't provide an easy way to catch the "OK" button being hit at this point in their sandboxed environment. Looks like you did the best you could with what you had to work with. – Michael Dautermann Sep 03 '13 at 13:54
  • @MichaelDautermann cool. At least I am on the right track then :) – Mikael Sep 03 '13 at 14:04