Playing around with the great Native Toolbar from Greg (o;
Now when I want to change a toolbar icon when it is pressed to signal a running process, it accepts disabling it so it can’t be pressed any further with:
item.Enabled = False
But when I want to change the icon with:
item.SetIcon(SFIconName)
Xojo refuses to compile with:
Window1.NSToolbar1.ItemPressed, line 4
There is more than one method with this name but this does not match any of the available signatures.
item.SetIcon(pencil)
SOSToolbar.NSToolbarItem.SetIcon(p As Picture)
SOSToolbar.NSToolbarItem.SetIcon(p As Ptr)
SOSToolbar.NSToolbarItem.SetIcon(SFSymbolName As String, variableValue As Double = -1, accessibilityDescription As String = "")
Is your pencil variable of type Picture, Ptr or String?
Hmm…still not getting the hang out of Native Toolbar methods…
Bare with me, I started in my youth with vacuum tubes electronics, z80 assembler and Forth language
This is documented:
**items() As SOSToolbar.NSToolbarItem()**
Returns a list of toolbar items that are on the toolbar
So when I want to get all items, I get a compile error:
Var items() As New SOSToolbar.NSToolbarItem()
Type mismatch error. Expected class SOSToolbar.NSToolbarItem, but got class SOSToolbar.NSToolbarItem
Var items() As New SOSToolbar.NSToolbarItem()
Recently I got a lot of those expected A but got A, always the same class name…so not helping me (o;
The itemsMethod you mention above returns an array of type SOSToolbar.NSToolbarItem.
When declaring a variable you call items as type SOSToolbar.NSToolbarItem it is not expecting to be assigned to an array - you added parenthesis () after items, so I think the compiler is confused, thus the message you are getting.
Try removing the parenthesis so it is just:
Var item As New SOSToolbar.NSToolbarItem() // creates a single toolbar item
But, why do you need an array of the items you added to the SOSToolbar.NSToolbar? The toolbar events only need an array of the item Identifiers (their names as Strings).
As you create/add each item to the toolbar, add its Identifier to an array property of type String and return that in the events. That’s what I did.
If you want the value of the items() method, you can just call the method in one of the toolbar events like so: