Lazarus

Programming => Operating Systems => macOS / Mac OS X => Topic started by: tcaland on April 30, 2021, 03:42:24 pm

Title: Using native macOS AppKit APIs from Lazarus for GUIs
Post by: tcaland 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
Title: Re: Using native macOS AppKit APIs from Lazarus for GUIs
Post by: trev 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 (https://wiki.freepascal.org/Portal:Mac) ?

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 (https://wiki.freepascal.org/ObjCParser) 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.
Title: Re: Using native macOS AppKit APIs from Lazarus for GUIs
Post by: tcaland 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
Title: Re: Using native macOS AppKit APIs from Lazarus for GUIs
Post by: trev 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 (https://wiki.freepascal.org/FPC_PasCocoa). You should probably look at all the Cocoa Internals (https://wiki.freepascal.org/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.
Title: Re: Using native macOS AppKit APIs from Lazarus for GUIs
Post by: tcaland 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