Delphi - OSX - 如何扩展NSWindowDelegate

Jam*_*mie 6 delphi macos cocoa

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].
Run Code Online (Sandbox Code Playgroud)

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

Seb*_*n Z 5

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

  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;
Run Code Online (Sandbox Code Playgroud)

在实现需要这些附加方法的类时,除了Delphi附带的接口之外,只需添加您的接口.

  TMyWindowDelegate = class(TOCLocal, NSWindowDelegate, NSWindowDelegateEx)
  // ...
  end;
Run Code Online (Sandbox Code Playgroud)