On Oct 24, 2008, at 11:51 PM, Corbin Dunn wrote:


On Oct 24, 2008, at 2:26 PM, Iceberg-Dev wrote:


On Oct 24, 2008, at 1:20 AM, Corbin Dunn wrote:


On Oct 23, 2008, at 1:38 PM, Iceberg-Dev wrote:

Solution not found in the cocoabuilder archive.

Problem:
--------

I have a list of files and folders.

I can add items to this list through a standard NSOpenPanel dialog.

When a folder is already in the list, I want to prevent the user from selecting it from the NSOpenPanel dialog.

I can do this with:

- (BOOL) panel:(id)sender shouldShowFilename:(NSString *) inFileName;

The problem is that this prevents the user from selecting a file within this folder from the NSOpenDialog.

Question:
---------

Is there a way to prevent a folder from being selected but still allow a file within this folder to be selected?

Yes; I think just calling setCanChooseDirectories:NO will work.

If not, then:

1. Don't use shouldShowFilename:
2. Call setCanChooseDirectories:NO
3. Call beginForDirectory:.. types:(your types)

If you have to do some specific dynamic processing to turn on/off enabled types, then you may be out of luck.

Feel free to log a bug requesting to make this process easier. (I already do have some bugs logged for this ability to be easier, so I am aware of the problem).

Hmm. Actually, I want the user to be able to choose a folder/ directory as long as it's not already in my list of files/folders.

Okay - I assumed you wanted only files.



Otherwise, setCanChooseDirectories:NO would work,

Or am I missing something and you're suggesting to call setCanChooseDirectories:NO:NO from the panel:shouldShowFilename: delegate method?

No; don't do that. You have to use shouldShowFilename: and implement -isValidFilename to validate the file when the user hits enter. Sorry -- there isn't any other way around it -- you can't have a folder disabled and still browseable with the current API.

I'd recommend just accepting all folders, and if it is already in your list, then just let the user choose the duplicate, and handle it as a nop.

OK, I will file an enhancement request because I think being able to disable a folder yet allow access to its contents can make sense in multiple cases. It would just require disabling the Open button.

Maybe something like [NSNavView setCanSeeContentsOfDisabledDirectories:YES];


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to