NSSavePanel's required/allowed types

  • Hello,

    I have searched archive but could not find exactly what I want.

    I have a NSSavePanel in my program for saving images. It has an accessory
    view with NSPopUpButton to choose image type (similar to Apple Preview). And
    I want to implement exactly the same behaviour like Preview does: when popup
    selection is changed, required-allowed files types (extension) for panel
    must be changed.

    Using setAllowedFileTypes, setAllowsOtherFileTypes, setRequiredFileType
    combinations works fine, except in this situation: lets say currently file
    name is myImage.tiff and popup shows "TIFF". I rename file to
    MyImage.jpgand change popup to JPEG. File name is converted into
    MyImage.jpg.jpg.

    The question is - how to avoid extra extension in specified situation?
    Preview does not have such a problem.

    By the way, when using TIFF and JPEG allowed types should be tiff, tif and
    jpeg, jpg. If type would be only one (for example png) then only
    setRequiredFileType is needed to call and that's all. But more than one type
    causes mentioned problems.

    Any help would be very appreciate.

    p.s. sorry for my poor English.

    Jonas S.
  • How about - (BOOL)panel:(id)sender isValidFilename:(NSString *)
    filename Panel delegate method?

    - Apparao.

    On Oct 3, 2007, at 10:44 PM, Jonas S wrote:

    > Hello,
    >
    > I have searched archive but could not find exactly what I want.
    >
    > I have a NSSavePanel in my program for saving images. It has an
    > accessory
    > view with NSPopUpButton to choose image type (similar to Apple
    > Preview). And
    > I want to implement exactly the same behaviour like Preview does:
    > when popup
    > selection is changed, required-allowed files types (extension) for
    > panel
    > must be changed.
    >
    > Using setAllowedFileTypes, setAllowsOtherFileTypes,
    > setRequiredFileType
    > combinations works fine, except in this situation: lets say
    > currently file
    > name is myImage.tiff and popup shows "TIFF". I rename file to
    > MyImage.jpgand change popup to JPEG. File name is converted into
    > MyImage.jpg.jpg.
    >
    > The question is - how to avoid extra extension in specified situation?
    > Preview does not have such a problem.
    >
    > By the way, when using TIFF and JPEG allowed types should be tiff,
    > tif and
    > jpeg, jpg. If type would be only one (for example png) then only
    > setRequiredFileType is needed to call and that's all. But more than
    > one type
    > causes mentioned problems.
    >
    > Any help would be very appreciate.
    >
    > p.s. sorry for my poor English.
    >
    > Jonas S.
    >
  • On 10/4/07, Apparao <apparao...> wrote:
    >
    > How about - (BOOL)panel:(id)sender isValidFilename:(NSString *)filename
    > Panel delegate method?
    >
    > - Apparao.
    >

    Nope. This is called after "- (NSString *)panel:(id)sender
    userEnteredFilename:(NSString *)filename confirmed:(BOOL)okFlag". And, of
    course, only when user clicks on Save. It is to late to change something,
    because I want, that user would not able to see "MyImage.jpg.jpg" after type
    popup change.

    Jonas S.
  • On 10/4/07, Apparao <apparao...> wrote:
    >
    > I guess, best option is Filename extension hiding. Did you tried with
    > Extension hiding methods in NSSavePanel
    > - Apparao
    >

    Actually not to good, because this eliminates ability to choose between jpg
    and jpeg.

    I would be able to solve my problem, if would be possibility to manually set
    file name is save panels field. But could not figure out how to do this.
    Even I am not sure if this possible at all.
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today