Skip navigation.
 
mlAlert while an open panel is in front
FROM : Arthur VIGAN
DATE : Thu Jan 16 21:01:34 2003

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_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
No related mails found.