Skip navigation.
 
mlRe: NSOpenPanel isn't listening to me? I told it to only allow .zip and .xml!
FROM : Andy Lee
DATE : Sun Jun 25 17:21:11 2006

On Jun 23, 2006, at 3:00 PM, Matt Neuburg wrote:
> Saying -setAllowedFileTypes: to an NSOpenPanel while the panel is 
> showing
> causes no change in what's selectable. Evidently you're supposed to 
> specify
> the allowed file types when you start running the panel. Thus it 
> appears
> that -setAllowedFileTypes: is useless, which is weird, because in 
> that case,
> why does it exist? That, at least, is the conclusion reached during a
> discussion of this issue at a different venue (a newsgroup). I 
> myself am
> just confused and would like to know how this is supposed to work.


I'm confused too.  I was wondering if -setAllowedFileTypes: is 
obsolete and should be deprecated, but from a quick Google it looks 
like it was *added* in Panther.

I wonder about the case where you present a save panel in a sheet, 
and you have two windows with their own save panels in their own 
sheets, but you want the allowed file types to be different in the 
two windows.  Presumably you do this by passing different values to -
setAllowedFileTypes: just before opening each sheet.  So what does 
[[NSSavePanel savePanel] allowedFileTypes] return?  Is it the most 
recent value you passed to -setAllowedFileTypes:?

I wonder if this confusion is due to design holdovers from the pre-
OSX days, when both save panels and open panels were very modal.

> I would
> think that being able to change the allowed file types while the 
> panel is
> open would be useful. m.


I just came across this method, along with the delegate method it 
mentions:

> validateVisibleColumns
>
> Validates and possibly reloads the browser columns visible in the 
> receiver by invoking the delegate method panel:shouldShowFilename:.
>
> - (void)validateVisibleColumns
>
> Discussion
>
> You might use this method if you want the browser to only allow 
> selection of files with certain extensions based on the selection 
> made in an accessory-view pop-up list. When the user changes the 
> selection, you would invoke this method to revalidate the visible 
> columns.


I guess this is how you can change the file types while the panel is 
open.  It implies that it's possible for the panel not to obey the 
list in -allowedFileTypes.

With all this confusion, I'm glad my app is read-only.  :)  Or maybe 
it's really simple and I'm just not understanding.

--Andy

Related mailsAuthorDate
mlRe: NSOpenPanel isn't listening to me? I told it to only allow .zip and .xml! Matt Neuburg Jun 23, 21:00
mlRe: NSOpenPanel isn't listening to me? I told it to only allow .zip and .xml! Andy Lee Jun 25, 17:21