8

TButton と TSavedialog を含む (Delphi XE2) Firemonkey サンプル プログラムを 2 つの異なるフィルタとともに作成しました。(TSaveDialog コンポーネントは、Win32/Win64 および OS X プラットフォームをサポートしています。)

Win32/Win64 では問題なく動作しますが、OS X (VirtualBox/OS X 10.7.x) で Savedialog フィルターが表示されない理由はわかりません。

OS X で動作させるにはどうすればよいですか?

procedure TForm1.Button_SaveClick(Sender: TObject);
begin
  SaveDialog.Filter:='Format_1 (*.fmt1)|*.fmt1|Format_2 (*.fmt2)|*.fmt2';

  If Savedialog.Execute Then ShowMessage(SaveDialog.FileName+#13+'Selected filterindex: '+Inttostr(SaveDialog.FilterIndex));
end;
4

2 に答える 2

3

The Save dialog is not constructed in Delphi but calls the native MAC OSX dialog (NSSavePanel). This does not have a user selectable filter.

When you execute a save dialog, Delphi passes the filter as an array to NSSavePanel.SetAllowedFileTypes which determines what extensions the OSX dialog will allow the user to specify - but there is no selectable list.

To allow the user to select from a list, you would need to create your own filetype selection dialog box and then take that selection and pass to the savedialog as the default file type and the only filter item.

The alternative of creating a completely new fileSave dialog is not easy as the Firemonkey tree component seems to insist on expanding all its nodes and hence performs a complete traverse of all the files on your hard drive. In any case, MAC users will be familiar with the standard dialog.

于 2012-10-22T10:35:21.320 に答える