I know right now there is the NSToolbar extension for macOS, but then I realized we have access to the source code, so why not add it to the engine and make it cross-platform. So far the Mac version is working, then next is to get it working on Windows. The one great thing about this is now we can use stack images as the icons (as seen below)
And what does GTK offer/require?
Your ambition is impressive, but be forewarned: sometimes wrapping everything for us scripters uniformly across platforms is a much bigger task than writing the underlying OS calls.
Hats off if you’re up for this, but I wouldn’t think less of you if it was put off for a while to think over the syntax and other implementation details. There be dragons.
Yeah, it took a few minutes to write the toolbar extension, but it took a long time to get it working built-in. I decided to do it this way because I was having issues writing a Windows extension. Linux has GTKToolbar so will be able to use that.
This is great stuff
, Emily! Could you spin up a demo stack on your Git and drop the link in the release notes? That way we can all dive in and break things - I mean, explore it - nice and quickly.
Thanks a lot ![]()
Yes there is a demo stack and full documentation (but for some reason it doesn’t get picked up on Windows, sorry)
To use the toolbar, you need to create a toolbar control
create toolbar <toolbarName> in this stack
You then create toolbar items
set the itemLabel[<toolbarItemName] of toolbar <toolbarName> to <toolbarLabel>
set the itemIcon[<toolbarItemName] of toolbar <toolbarName> to <nameOfImage>
The nameOfImage is either the name of an image in the stack or a SFSymbol (on macOS)
Once the toolbar items are created, you add them to the toolbar control
set the itemNames of toolbar <toolbarName> to <toolbarItemName> & return & <toolbarItemName>
When the toolbar item is clicked you will get the message
toolbarItemClicked pToolbarItemName
So all together
on OpenCard
if (there is not a toolbar "mainBar") then
create toolbar "mainBar" in this stack
set the itemLabel["fileNew"] of toolbar "mainBar" to "New"
set the itemLabel["fileOpen"] of toolbar "mainBar" to "Open"
set the itemLabel["fileSave"] of toolbar "mainBar" to "Save"
set the itemIcon["fileNew"] of toolbar "mainBar" to "doc.badge.plus"
set the itemIcon["fileOpen"] of toolbar "mainBar" to "folder"
set the itemIcon["fileSave"] of toolbar "mainBar" to "square.and.arrow.down"
set the itemNames of toolbar "mainBar" to "fileNew" & return & "fileOpen" & return & "fileSave"
set the toolbarVisible of toolbar "mainBar" to true
end if
end OpenCard
on toolbarItemClicked pItemName
switch pItemName
case "fileNew"
doMenu "New Stack"
break
case "fileSave"
save this stack
break
end switch
end toolbarItemClicked

