NSSavePanel delegate Methods called by NSOpenPanel
NSSavePanel delegate Methods called by NSOpenPanel
- Subject: NSSavePanel delegate Methods called by NSOpenPanel
- From: Daniel Demiss <email@hidden>
- Date: Thu, 9 Jul 2009 15:40:41 +0200
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@hidden)
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:
This email sent to email@hidden