Alert while an open panel is in front
Alert while an open panel is in front
- Subject: Alert while an open panel is in front
- From: Arthur VIGAN <email@hidden>
- Date: Thu, 16 Jan 2003 21:01:34 +0100
Hi,
I have a little problem with my application. I use a sheet to run an
open panel for the user to choose a folder, but I don't want the user
to choose particular folders. How can I run an alert panel while the
open panel is still active?
I wrote the following code, but the problem is that it does run the
alert panel and then close the sheet whithout letting the user choose
another folder.
//--------------------
- (IBAction)choosePath:(id)sender
{
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection:NO];
[openPanel setCanChooseDirectories:YES];
[openPanel setCanChooseFiles:NO];
[openPanel setPrompt:@"Choose a folder"];
[openPanel beginSheetForDirectory:nil
file:nil
types:nil
modalForWindow:[self window]
modalDelegate:self
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
//--------------------
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
if(returnCode == NSOKButton)
{
if(isDirectoryAllowed == YES)
{
// do some stuff
}
else
{
NSRunAlertPanel(@"Error",
@"You're not allowed to choose that folder. Please choose
another one.",
@"OK", nil, nil);
}
}
}
Is there a solution?
Thanks in advance,
Arthur
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.