Re: NSOpenPanel and the New Folder button
Re: NSOpenPanel and the New Folder button
- Subject: Re: NSOpenPanel and the New Folder button
- From: John Stiles <email@hidden>
- Date: Wed, 10 Sep 2003 18:12:13 -0700
On Wednesday, September 10, 2003, at 05:58 PM, David Remahl wrote:
On den 11 september 2003, at 02:40:16AM, John Stiles wrote:
On Wednesday, September 10, 2003, at 05:14 PM, Dustin Voss wrote:
On Tuesday, September 9, 2003, at 05:17 PM, John Stiles wrote:
I am making an NSOpenPanel which can only select folders:
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setCanChooseFiles:NO];
[panel setCanChooseDirectories:YES];
[panel setResolvesAliases:YES];
[panel setAllowsMultipleSelection:NO];
[panel setPrompt:@"Choose"];
int result = [panel runModalForDirectory:myDirectory file:NULL
types:NULL];
I want the user to have the ability to create a folder from this
panel. I think an NSSavePanel can do this, but I don't know how to
convince an NSOpenPanel to do so.
What can I do? Thanks.
An undocumented method: [panel _setIncludeNewFolderButton:YES];
Is this safe?
If this means the program will break under OS X 10.4.x or something,
it would be very difficult to justify. This app absolutely has to
work out-of-the-box.
You are safe if you first check for the presence of the method.
Something like this:
if( [panel respondsToSelector:@selector(_setIncludeNewFolderButton:)]
) /* The method is there as expected. */
[panel _setIncludeNewFolderButton:YES];
else if( [panel
respondsToSelector:@selector(setIncludeNewFolderButton:)] ) /* perhaps
it was made public */
[panel setIncludeNewFolderButton:YES];
else /* The method disappeared. Do nothing. */
NSLog(@"Couldn't enable New Folder-button." );
Of course, to avoid compiler warnings, you would create just the
interface part of a category on NSSavePanel like this:
@interface NSSavePanel (__HackyBlizzardNewFolderCategory)
- (void)_setIncludeNewFolderButton:(BOOL)yn;
- (void)setIncludeNewFolderButton:(BOOL)yn;
@end
/ Regards, David Remahl
Cooooooool. That's what I'll do.
Thanks for imparting your Cocoa knowledge. I'm learning fast on this
mailing list :)
_______________________________________________
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.