For anyone looking for a native macOS toolbar, I made one available on the Xojo store recently. You can find more information and a demo link on my website.
This looks great! Any chance of extending this or creating a similar project for Windows?
Youâll need to put the dylib into the copy files step again.
Iâll do this to test, but App crash in Window1.Opening doing âRebuildToolbarâ when AddItem : nstoolbar1.AddItem(MakeItem(âTrashâ, âtrashâ))
Interesting. Youâre the second person to report that and I have no idea why yet.
Could you separate that line into two like this?
Dim item as SOSToolbar.NSToolbarItem = MakeItem(âTrashâ, âtrashâ)
nstoolbar1.AddItem(item)
And tell me it item is Nil?
Well the good news is that I can reproduce it now⊠working on a solution.
âŠand Fixed.
Version 1.0.2 of my Native macOS Toolbar classes are now available. A special shout out to @Valdemar_De_SOUSA for pointing out a critical toolbar selection bug.
This version adds an NSToolbarItem.IsSelectable property which indicates whether or not the toolbar item stays highlighted when it is selected. Coupled with setting the Bordered property to False, you can now have a preferences toolbar that behaves like a Tab Bar where one item is always selected.
The new version can be downloaded from here.
Another test problem, how do you use âTagâ in SOSToolbar.NSToolbarItem ?
It always return 0 when you add a tag at construction, and -1 when you donât.
Fixed. tag will only take integers now since thatâs what macOS supports under the hood.
I get this message when launching the Demo (what do I do?)
Window1.NSToolbar1.SelectableItemIdentifiers Declaration
NSToolbar1 on Window1 implements the event âSelectableItemIdentifiers,â but its superclass SOSToolbar.NSToolbar has already implemented the event.
Function SelectableItemIdentifiers() As String()
Thanks.
It works when I remove the NSToolbar1.SelectableItemIdentifiers event !!!
Right. I moved that feature to a property of the items themselves. Now you just set the âisSelectableâ property and whenever the toolbar asks for that info, it asks the items.
Iâve had a recent query about how to move add this module into a text project.
The encrypted SOSToolbar module in the sample project contains not only methods and properties, but also other classes. Because of the encryption, these files must be kept together as a binary object.
The solution is pretty straightforward:
- In your project, create a folder called SOS_Toolbar
- Copy & Paste the SOSToolbarHelpers module from the sample project to the SOS_Toolbar folder in your project.
- Go to the sample project and select the SOSToolbar module.
- Right-click on the module and select Export.
- Save the file into the folder where your project files are.
- Bring your project to the foreground
- Drag the exported file to your project while holding down the CMD and OPT keys so it gets added to your project as an external item.
- Save your project
HmmâŠ
Somehow the toolbar icons are always disabledâŠalso in the demo project where the itemPressed event should trigger label1.Text = "Pressed: " + item.Label.
Something missing to get the itemPressed events?