Re: NSOpenPanel setDirectory to a package
Re: NSOpenPanel setDirectory to a package
- Subject: Re: NSOpenPanel setDirectory to a package
- From: Dale Jensen <email@hidden>
- Date: Thu, 19 Jun 2008 08:47:01 -0500
On Jun 18, 2008, at 5:44 PM, Ken Thomases wrote:
On Jun 18, 2008, at 5:18 PM, Dale Jensen wrote:
I have an "application picker" bit in my preferences, which allows
the user to select an app to do something. 90% of the time, I
presume, this will be a package, not a single file. My code is thus:
[oPanel setTreatsFilePackagesAsDirectories: NO];
NSString *filePath = @"/Applications/Preview.app"; // just for
example, it doesn't really default this way
[oPanel setDirectory:filePath];
I think those are the only relevant bits. When then open panel
comes up, the application is selected, and you're looking at the
root level of the package (ie: "Contents"). That's not what I
want, and not what I think the above code should result in. I
think that it should show the applications folder, with Preview
selected (but not "open" to the Contents folder.)
I disagree. There's a difference between restricting what the user
can do and a program restricting what it can do to itself.
setTreatsFilePackagesAsDirectories:NO is about the program
restricting the user, not itself. If the program then proceeds to
tell the NSOpenPanel to start in a particular directory, it should
do so, even if that would not be something the user would be allowed
to do.
To accomplish what you want, you should specify the filename to the
begin... or runModal... method that you invoke.
Thanks, Ken. Between you and another respondent, I've sorted it out.
See that bit up there that says "I think those are the only relevant
bits"? Well, not the case. The next line was "runModalForTypes:"
which was, of course, the wrong method to use. Found, and implemented
"runModalForDirectory:file:types:" and now it works the way I like
(save that it doesn't scroll to the selection in the list.)
Yet another case of getting confused in the frameworks -- I don't know
why I had originally used that method, probably the first thing that I
ran across, and, as it presented a "90%" solution, I figured I was
just missing something in the set up.
Thanks again!
dale
_______________________________________________
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