gpt4 book ai didi

macos - Delphi - OSX - 如何扩展 NSWindowDelegate

转载 作者:行者123 更新时间:2023-12-03 15:00:53 35 4
gpt4 key购买 nike

当前 Delphi 中的 NSWindowDelegate 实现非常有限。它不包括诸如 windowWillResize:toSize: 之类的事件

我该如何扩展它?我可以在 source\rtl\osx'Macapi.Appkit.pas 中看到代码,因此我尝试将该文件复制到我的应用程序文件夹中并将其包含在项目中。

但是,这样做之后我得到了很多:

Unit FMX.[unit-name-here] was compiled with a different version of FMX.[other-unit-name-here].

扩展它的适当方法是什么?我怎样才能消除这些错误?

最佳答案

您可以创建自己的界面来添加缺少的方法。

  NSWindowDelegateEx = interface(IObjectiveC)
[{ Press Ctrl+Shift+G to insert a guid here }]
procedure windowDidEnterFullScreen(notification: NSNotification); cdecl;
function window(window: NSWindow; willUseFullScreenContentSize: NSSize): NSSize; cdecl; overload;
function window(window: NSWindow; willUseFullScreenPresentationOptions: NSApplicationPresentationOptions): NSApplicationPresentationOptions; cdecl; overload;
end;

当实现需要这些附加方法的类时,只需在 Delphi 自带的接口(interface)之外添加您的接口(interface)即可。

  TMyWindowDelegate = class(TOCLocal, NSWindowDelegate, NSWindowDelegateEx)
// ...
end;

关于macos - Delphi - OSX - 如何扩展 NSWindowDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30465685/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com