Cocoa: TSaveDialog ofOverwritePrompt issues
Original Reporter info from Mantis: crlab @neurolabusc1
-
Reporter name: Chris Rorden
Description:
The TSaveDialog does not implement ofOverwritePrompt properly.
1. The TSaveDialog ALWAYS generates an Overwrite Prompt, regardless of the setting of ofOverwritePrompt.
2. An Overwrite Prompt will be generated for "unit1.pas" but not when selecting "unit1" with ".pas" in the filter, even though both functions return precisely the same filename, e.g. "unit1.pas" that will overwrite a file.
3. TSaveDialog.Filter does not correctly set file extensions with two dots, e.g. TSaveDialog.Filter := 'Compressed Archive (.tar.gz)|*.tar.gz' will return 'filename.gz' not 'filename.tar.gz'. This impacts any format with double extensions, e.g. NII.GZ, TAR.GZ, TAR.BR, TAR.BZ, TAR.LPAQ, TAR.XZ, TAR.ZST
Steps to reproduce:
function TForm1.NiftiSaveDialogFilename(isOverwritePrompt: boolean): string;
const
kOutFilter = 'Pascal (.pas)|*.pas|Compressed NIfTI (.nii.gz)|*.nii.gz|Volume of interest (.voi)|*.voi|Blender Volume (.bvox)|*.bvox|OSPRay Volume (.osp)|*.osp|TIF (.tif)|*.tif|NRRD (.nrrd)|*.nrrd|Compressed NRRD (.nhdr)|*.nhdr';
kMaxExt = 8;
kExt : array [1..kMaxExt] of string = ('*.pas', '*.nii.gz', '*.voi', '*.bvox', '*.osp', '*.tif', '*.nrrd', '*.nhdr');
var
dlg : TSaveDialog;
begin
result := '';
dlg := TSaveDialog.Create(self);
if isOverwritePrompt then
dlg.Options := [ofEnableSizing, ofViewDetail, ofOverwritePrompt]
else
dlg.Options := [ofEnableSizing, ofViewDetail]; //NO disable ofOverwritePrompt
dlg.Title := 'Save NIfTI volume';
dlg.FileName:= 'unit1';
dlg.Filter := kOutFilter;
dlg.DefaultExt := kExt[1];
dlg.FilterIndex:= 1;
if dlg.Execute then
result := dlg.FileName;
dlg.Free;
end;
Mantis conversion info:
-
Mantis ID: 37925
-
OS: Darwin
-
OS Build: 10.14.6
-
Build: 64001
-
Platform: MacBook
-
Version: 2.1 (SVN)