• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Alert while an open panel is in front
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Patching an application (long)
  • Next by Date: Re: HFSPromised, other file systems, and what is the deal?
  • Previous by thread: Re: HFSPromised, other file systems, and what is the deal ?
  • Next by thread: Re: HFSPromised, other file systems, and what is the deal?
  • Index(es):
    • Date
    • Thread