FireMonkey / Rad Studio XE2:如何在OS X上显示SaveDialog过滤器? [英] FireMonkey/Rad Studio XE2: How can I show the SaveDialog filter on OS X?

查看:194
本文介绍了FireMonkey / Rad Studio XE2:如何在OS X上显示SaveDialog过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个(Delphi XE2)Firemonkey示例程序,其中包含一个TButton和一个具有两个不同过滤器的TSavedialog。
(TSaveDialog组件支持Win32 / Win64和OS X平台)。

I created an (Delphi XE2) Firemonkey sample program which contains a TButton and a TSavedialog with two different filters. (The TSaveDialog component supports the Win32/Win64 and OS X platform.)

它在Win32 / Win64上工作正常,但现在我不知道为什么不显示OS X上的Savedialog过滤器(VirtualBox / OS X 10.7.x)。

It works fine on Win32/Win64, but I don't now why it does not show the Savedialog filters on OS X (VirtualBox/OS X 10.7.x).

如何让它在OS X上工作?

How can I get it to work on 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;


推荐答案

保存对话框不是在Delphi中构建的,而是调用本机MAC OSX对话框(NSSavePanel)。这不具有用户可选择的过滤器。

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

执行保存对话框时,Delphi将过滤器作为数组传递给NSSavePanel.SetAllowedFileTypes,它们决定了OSX对话框的哪些扩展允许用户指定 - 但是没有可选列表。

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.

为了允许用户从列表中进行选择,您需要创建自己的文件类型选择对话框然后采取该选择并传递给savedialog作为默认文件类型和唯一的过滤器项。

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.

创建一个全新的文件保存对话框的替代方法不容易,因为Firemonkey树组件似乎坚持扩展其所有节点,从而执行硬盘驱动器上所有文件的完整遍历。无论如何,MAC用户将熟悉标准对话框。

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.

这篇关于FireMonkey / Rad Studio XE2:如何在OS X上显示SaveDialog过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆