Re: Filtering File Names in NSOpenPanel
Re: Filtering File Names in NSOpenPanel
- Subject: Re: Filtering File Names in NSOpenPanel
- From: Andy Lee <email@hidden>
- Date: Thu, 7 Jul 2005 20:52:54 -0400
On Jul 7, 2005, at 3: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.
A delegate method was suggested earlier -- did you look at your
options? NSOpenPanel inherits from NSSavePanel, so it uses the same
delegate methods. In particular:
panel:shouldShowFilename:
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
Gives the delegate the opportunity to filter out items that it
doesn’t want the user to see or choose. The NSSavePanel sender sends
this message to the panel’s delegate for each file or directory
(filename) it is about to load in the browser. The delegate returns
YES if filename should be displayed, and NO if the NSSavePanel should
ignore the file or directory.
This sounds like what you want. In your implementation, check
whether filename ends with "sli.doc" and return YES if so, NO
otherwise. One line of code.
--Andy
_______________________________________________
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