Michel, thank you for those suggestions, but they seem to be related to drawing in the title bar of a metal window, while I’m trying to draw an image on top of a toolbar in a regular window. I’m not sure if drawing in the title bar is applicable to drawing in a toolbar.
Put the canvas into the Toolbar, if you don’t have the MBS plugin I can provide the code.
Make the Toolbar background transparent, move the window content up behind the toolbar and draw there. You could even insert a NSVisualEffectView into the window, under your canvas to bring the Toolbar background back.
Switch the window to Document, add a toolbar, and all you have to do is to position the canvas on top of the toolbar, and draw the picture where you want it.
I just did that in 5 minutes by modifying Jim’s project.
[quote=463253:@Michel Bujardet]Switch the window to Document, add a toolbar, and all you have to do is to position the canvas on top of the toolbar, and draw the picture where you want it.
I just did that in 5 minutes by modifying Jim’s project.
Amazing what preconceptions can do to programers :/[/quote]
Obviously I tried positioning a canvas on top of the toolbar and drawing it where I wanted it. That would be the first thing you would try, wouldn’t it?
It turns out the issue is dark mode. I neglected to mention I’m running in dark mode (and will need a solution that works in both dark and light mode), and you apparently had the preconceptions that I was using light mode and that anything that works in light mode will work the same way in dark mode.
Evidently you can’t position a canvas on top of a toolbar in dark mode and have it visible. The toolbar will always cover the canvas. Or at least I haven’t discovered a way to make that not happen.
[quote=463251:@Sam Rowlands]There are several options.
Put the canvas into the Toolbar, if you don’t have the MBS plugin I can provide the code.
Make the Toolbar background transparent, move the window content up behind the toolbar and draw there. You could even insert a NSVisualEffectView into the window, under your canvas to bring the Toolbar background back.
is a lot easier, go with number 1.[/quote]
Thanks, Sam. I do have the MBS plugin, but I was hoping to figure out a way to make it work with Xojo’s built-in toolbar and I believe the MBS plugin route means junking the Xojo toolbar and replacing it with a Cocoa control. Is that right?
Might have to go that route, but that also means having to do a completely different toolbar on Windows (and finding a way to display a canvas in it).
I don’t know how I’d go about making the toolbar background transparent. A declare? Setting “me.transparent = true” has no effect.
I don’t use the MBS plugins myself, so I can’t comment. I do most of it directly with declares, as of yet, I’ve not had to replace the Xojo toolbar to be able to hack it.
Again, I have very little experience with Windows, so I can’t make a sound judgement. However my gut tells me that you may want to consider dropping the built-in toolbar and faking it if you want this kind of functionality x-plat.
A couple of declares will do it. I can share them with you if you.
I use them https://www.ohanaware.com/hdr/, so I can place controls in the toolbar area, without being forced to lock them to Apple’s toolbar specifics.