Delphi - OSX - How to Extend NSWindowDelegate

The current implementation of NSWindowDelegate in Delphi is very limited. It does not include events such as windowWillResize: toSize:

How can I extend it? I can see the code in the source \ rtl \ osx'Macapi.Appkit.pas, so I tried to make a copy of this file in the application folder and include it in the project.

However, after that I get a lot:

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

What would be a suitable way to expand it? How can I get rid of these errors?

+6
source share
2 answers

You can create your own interface that will add the missing methods.

  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; 

When implementing a class that needs these additional methods, just add your interface in addition to the interface that comes with Delphi.

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

To get rid of the error, copy the FMX file as well. [other-unit-name-here] in the project folder. It needs to be recompiled because you changed some kind of interface.

0
source

Source: https://habr.com/ru/post/987953/


All Articles