Forum > macOS / Mac OS X
Using NSToolbar in Lazarus
CCRDude:
Not a question, but some code to offer this time :)
Inspired by a post on a German Lazarus forum, I put some effort into making it easier to use a NSToolbar in Lazarus (e.g. the one with the buttons right next to the window title in the title bar).
It supports standard buttons, button groups, search bars, share and menu items. Images can be used from system default images, images that are part of the bundle, or TImageList (with a few bugs remaining). You can assign actions to toolbar items, or direct captions and titles.
It's missing the -WM13.0 specific centeredItemIdentifiers because I cannot compile for that currently, and making a full TComponent out of it, but otherwise quite usable.
https://gitlab.com/ccrdude-pascal/firefly-macos/-/tree/main/source
dbannon:
Hey Dud
Is this something that should be mentioned on https://wiki.freepascal.org/FPC_PasCocoa ?
Davo
Hansaplast:
Thanks for sharing! Going to give it a try right away! :)
Hansaplast:
Unfortunately, Lazarus produces and error when trying to compile FireFlyMacOS:
--- Code: ---NSGraphicsContext.inc(367,13) Error: Illegal type conversion: "Pobjc_object" to "NSCompositingOperation"
--- End code ---
In: ./lazarus/lcl/interfaces/carbon/pascocoa/appkit/NSGraphicsContext.inc
I've tried it with Lazarus from trunck:
Lazarus 3.99 (rev main_3_99-1411-g2c81dff5d9) FPC 3.3.1 aarch64-darwin-cocoa (a few weeks old)
Lazarus 3.99 (rev main_3_99-1502-g05af6f9a4f) FPC 3.3.1 aarch64-darwin-cocoa (most recent)
Any tips how to get this to work? 😊
CCRDude:
I did have this under some circumstances as well (when trying to crate a package out of it). According to a post here in this forum, it's when an old PasCocoa unit is used?
In my project, I enforce macOS 11 using this option:
Project -> Project Options... -> Compiler Options -> Additions and Overrides -> Add -> Custom Option -> "-WM11.0".
Before adding this, it worked as well, but toolbar needed a different init, so there's one IFDEF in there.
Solving this issue would help me as well, since then I could wrap it into a package.
Or is this error occuring when you try to compile the package? Then it's the same I haven't solved yet.
Manually adding the search path and units to the uses part (Firefly.MacOS.Toolbar and Firefly.MacOS.Toolbar.Items) works without this error though :)
Navigation
[0] Message Index
[#] Next page