Recent

Author Topic: Using native macOS AppKit APIs from Lazarus for GUIs  (Read 1924 times)

tcaland

  • Newbie
  • Posts: 4
Using native macOS AppKit APIs from Lazarus for GUIs
« on: April 30, 2021, 03:42:24 pm »
Hello,

I am wondering if it's possibile to get access and use any of the AppKit APIs from Lazarus instead of using the cross platform LCL or mix with them in a macOS environment.

I would like to be access to use the latest macOS Big Sur APIs for example, like the cool new sidebar.

Is this easily possibile? I expect I would create GUI element in code vs GUI. Would it be easy to wrap native AppKit APIs and expose them as drag-and-drop component for the Lazarus IDE?

thank you

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1477
  • Former Delphi 1-7, 10.2 user
Re: Using native macOS AppKit APIs from Lazarus for GUIs
« Reply #1 on: May 01, 2021, 01:36:38 am »
I am wondering if it's possibile to get access and use any of the AppKit APIs from Lazarus instead of using the cross platform LCL or mix with them in a macOS environment.

Have you checked out the Wiki's Mac Portal ?

Quote
I would like to be access to use the latest macOS Big Sur APIs for example, like the cool new sidebar.
Is this easily possibile? I expect I would create GUI element in code vs GUI.

You would need to convert the missing Cocoa interface files as FPC 3.2.0 (and trunk) is only up to date to macOS 10.10. It shouldn't be too difficult to do.

Quote
Would it be easy to wrap native AppKit APIs and expose them as drag-and-drop component for the Lazarus IDE?

Way beyond my ken I'm afraid.
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65182 FPC 3.3.1 r49223 macOS 11.4 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

tcaland

  • Newbie
  • Posts: 4
Re: Using native macOS AppKit APIs from Lazarus for GUIs
« Reply #2 on: May 01, 2021, 10:11:55 am »
thank you @trev for the reply.

I read through the Mac Portal Wiki and I see some examples of using Cocoa specific APIs (like Drawers and Sheets), but I could not find a specific guide/example on how to access AppKit API, but probably it's there and I can't find it. Could you point me please to a simple example/source code where I can see how to add a simple NS<component> to a form?

Could I mix AppKit widgets with NS AppKit widgets freely in the same form?

Sorry if those are newbie questions. Thanks a lot

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1477
  • Former Delphi 1-7, 10.2 user
Re: Using native macOS AppKit APIs from Lazarus for GUIs
« Reply #3 on: May 01, 2021, 03:17:45 pm »
I read through the Mac Portal Wiki and I see some examples of using Cocoa specific APIs (like Drawers and Sheets), but I could not find a specific guide/example on how to access AppKit API, but probably it's there and I can't find it.

I don't think there is any guide specifically applicable to your request, but you can check out the /usr/local/share/fpcsrc/3.x.x/packages/cocoaint/src/appkit source directory for what's available.

Quote
Could you point me please to a simple example/source code where I can see how to add a simple NS<component> to a form?

Pure FPC examples can be found in the Wiki article FPC PasCocoa. You should probably look at all the Cocoa Internals articles.

Offhand, I don't know of any examples mixing the LCL and the native controls other than my recent Drawers contribution to the Wiki.

Quote
Could I mix AppKit widgets with NS AppKit widgets freely in the same form?

I'm not sure I even understand the question! Don't take that the wrong way, I'm only a simple lawyer who's just spent 4 hours converting an outdated Apple C code daemon example into non-deprecated C code daemon example so that I can now convert it into a Pascal daemon example.

I've probably helped as much as I can now, maybe someone else will take up the challenge.
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65182 FPC 3.3.1 r49223 macOS 11.4 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

tcaland

  • Newbie
  • Posts: 4
Re: Using native macOS AppKit APIs from Lazarus for GUIs
« Reply #4 on: May 04, 2021, 12:35:35 pm »
thank you @trev, you answered helped a lot. I will read the documents you indicated and I will try to make some experiments. Try my best to update this thread in case others need similar information


 

TinyPortal © 2005-2018