Hi all,

I'm a little confused by the following situation:

I have an NSPathControl (PopUp-Style) that should only
allow certain paths to be selected.

Therefore I have a controller-object that I set as the
delegate of the NSPathControl and the NSOpenPanel that
will be presented if a user clicks on the "Choose..."
item in the path-popup.

This is working fine except for the delegate method

- (NSString *)panel:(id)sender
userEnteredFilename:(NSString *)filename
         confirmed:(BOOL)okFlag

which somehow doesn't seem to be called.

More curiously:
If I trick the panel in selecting an "invalid" path
through creation of a new directory, I cannot open
that path - which at least is half of what I wanted
to accomplish in the first place...

I guess I'm doing something terribly and obviously
stupid here, but I just don't see it...

So any pointers will be much appreciated!

Thanks in advance,

Daniel

PS:
Below are the interesting methods from my controller-
class's implementation.

#pragma mark NSPathControlDelegate methods:
- (void)pathControl:(NSPathControl *)pathControl willDisplayOpenPanel: (NSOpenPanel *)openPanel
{
   [openPanel setAccessoryView:mAccessoryView];
   [openPanel setCanChooseFiles:NO];
   [openPanel setCanChooseDirectories:YES];
   [openPanel setCanCreateDirectories:YES];
   [openPanel setDelegate:self];
   [openPanel setDirectory:mValidBasePath];
}

#pragma mark NSSavePanelDelegate methods:
- (BOOL)panel:(id)sender
isValidFilename:(NSString *)filename
{
   return [self isValidPath:filename shouldPresentError:NO];
}

- (NSString *)panel:(id)sender
userEnteredFilename:(NSString *)filename
         confirmed:(BOOL)okFlag
{
   // not called at all!
   NSLog(filename);
   if (![self isValidPath:filename shouldPresentError:YES]) {
       NSLog (@"invalid path: %...@\nreturning nil...", filename);
       return nil;
   }

   NSLog (@"valid path!");
   return filename;
}
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to