Re: Filtering File Names in NSOpenPanel
Re: Filtering File Names in NSOpenPanel
- Subject: Re: Filtering File Names in NSOpenPanel
- From: Charilaos Skiadas <email@hidden>
- Date: Thu, 7 Jul 2005 14:18:07 -0500
What you could try is to get hold of the browser in the Open Panel,
set yourself as delegate and implement the appropriate methods to
have the browser only show the files you want it to. I would probably
be sitting in the panel's content view. You would probably need to
look at the docs for NSBrowser and NSFileManager for the directory
contents. Not sure if this is doable or optimal, but it's worth a
try. Haven't tried it myself.
On Jul 7, 2005, at 2:00 PM, Vince Ackerman wrote:
I need the user to point to and open certain files and they all end
in the "xxxxxxxsli.doc", the first part changes from month to
month. I guess I could just look at the file name OpenPanel returns
and then put up an error message if the user doesn't select the
right file.
Thanks,
Vince
On Jul 7, 2005, at 10:45, Charilaos Skiadas wrote:
On Jul 7, 2005, at 12:18 PM, Vince Ackerman wrote:
I need to run an OpenPanel that only allows the display of files
ending in "sli.doc" though the actual name maybe longer, such as
"2005071sli.doc" . I can see how to filter for only ".doc" but I
would like the panel to only find .doc files ending in "sli.doc".
Reading the NSSavePanel docs I see that the delegate handles file
names, but (as a wet behind the ears newbie) I'm not sure how to
use this. Can anyone clue me in?
You could try implementing
- (BOOL)panel:(id)sender isValidFilename:(NSString *)filename
in your delegate, and return NO if the file does not fit your
requirements, but this would not alter the displayed files, just
prevent the user from choosing an inappropriate file.
I would suggest rethinking your design though. Either your app
handles documents of type .doc, or it does not. There is no type
of document sli.doc, so it does not make sense to restrict to such
documents. If your app does indeed only open .doc files of a
particular nature, I would suggest creating your own document
type, maybe .slidoc or something, and renaming those files.
Of course, you could always implement your own open panel with a
browser and all, and do whatever you want with it, but I would
strongly advice against it, for a number of reasons.
Thanks
Vince
Haris
Haris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden