• 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
Re: NSOpenPanel Oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOpenPanel Oddity


  • Subject: Re: NSOpenPanel Oddity
  • From: Daniel Todd Currie <email@hidden>
  • Date: Tue, 4 May 2004 09:44:11 -0700

I did my open panel rather differently... Here's a -choosePath method that I use in one of my apps:

- (IBAction)choosePath:(id)sender
{
int result;
NSOpenPanel *oPanel = [NSOpenPanel openPanel];

[oPanel setCanChooseFiles:YES];
[oPanel setCanChooseDirectories:YES];
[oPanel setAllowsMultipleSelection:NO];
[oPanel setResolvesAliases:YES];
[oPanel setPrompt:@"Choose"];

result = [oPanel runModal];

if(result == NSOKButton)
{
[...]
}
}

This is the general implementation that I found somewhere in the cocoa docs.

Perhaps it would work better if you did [importOpenPanel runModalForTypes:[NSArray arrayWithObjects:@"bm2", nil]], and handle user response in that same method. But maybe you specifically don't want it to run modally? I've never tried to run an open panel modelessly...

Also, I couldn't help but notice that you set the prompt to @"Import...". I don't know how your app functions, but it seems most likely that clicking the open panel's prompt button will take you back to the application. However, the ellipsis in an button name is reserved in the AHIG for buttons that will open new dialogs. Just an FYI, please ignore my comment if you are actually opening a new dialog after the user presses the open panel's prompt button.

-- Daniel Currie


On 2004 May 03, at 14:19, Jean-Olivier Lancttt-D. wrote:

I must be missing something very stupid.

When my class gets an -import message, an open panel opens and then immediately closes. I can see it for half a second.

The didEndSelector does not get called. Heres' -import

- (void)import {
NSOpenPanel *importOpenPanel = [NSOpenPanel openPanel];

[importOpenPanel setTitle:@"Import..."];
[importOpenPanel setPrompt:@"Import..."];

[importOpenPanel beginForDirectory:nil
file:nil
types:[NSArray arrayWithObjects:@"bm2", nil]
modelessDelegate:self
didEndSelector:@selector(_importPanelDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}

Thanks,

-J.O.
_______________________________________________
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.


  • Follow-Ups:
    • Re: NSOpenPanel Oddity
      • From: "Jean-Olivier Lanctôt-D." <email@hidden>
References: 
 >NSOpenPanel Oddity (From: "Jean-Olivier Lanctôt-D." <email@hidden>)

  • Prev by Date: Re: NSTextField and bindings
  • Next by Date: Re: Objective-C question
  • Previous by thread: Re: NSOpenPanel Oddity
  • Next by thread: Re: NSOpenPanel Oddity
  • Index(es):
    • Date
    • Thread