Does anyone have any idea why my two apps have different coloured toolbars on Big Sur? They’re both Document windows with toolbars added. On Catalina they’re both grey like ClaroRead, but on Big Sur ClaroCapture is almost white - which I think is the default style on BS, but ClaroRead is not…
Are they both built with the same version of Xojo? We update SDKs from time to time and if one is older, that might be the cause.
No, both Xojo 2019r3.2. I set the apps up in different versions initially, ClaroRead is about 3 years older than Capture. I can’t see any differences in the code files regarding the toolbar’s properties though.
Check and make sure the Window Type is the same in both apps.
Yes, they’re both Document type. Interestingly, I just ran the code on my computer, which is now in dark mode, then to check what the toolbar looked like I changed it to light mode (while my app was running) and the toolbar was almost white, like Capture! So the issue is when ClaroRead starts up and macOS is in light mode. I’ve still no idea if that’s a Xojo issue, Mac beta issue, or it could still be an issue with my code seeing as Capture is fine
Are you using any declares on window open? Or Plugins?
Thanks for the advice Sam, it made me comment out all of the loading code and add it back in one section at a time!
On Open I add a NSButtonMBS to the window using the following code:
languageButton = new MyNSButtonMBS(…)
win = self.NSWindowMBS
It’s on that last line that the toolbar changes colour - when I add the button to the superview. And it only seems to happen when it’s called in the Open event. If I add it later (when I manually add another language option), the button is added with no change to the toolbar colour. Strange!
I was adding the button and hiding it for most configurations, so I can just not add it for now. But the problem still persists in multi-lingual version of the app (but only on Big Sur). I guess I can live with that for now unless anyone has any ideas around it? I tried a timer to add the button 5 seconds after launch, but it still had the problem.
Interesting, but not the first time I’ve seen a control on a window change the window!
What does this button do and why does it need to be constructed in code at run time?
I need a little language changing button in the title bar area for multi-lingual version so people can switch languages easily. Is there a better way to do this?
Not sure if it helps here…
I use for a Language switcher a Canvas. In MouseDown I create a Popup menu with language name and flag (remember to return true).
In the Paint Event I draw the flag and language name.
It is pretty simple, works cross platform and needs no plugin.
The difference is that I place it in the window and not at the tool bar.
hmm… There’s multiple ways to create a similar control (even hacking a standard popupmenu will do it), but positioning it in the top right hand corner, I only know of two ways to do it.
Which makes me wonder…
What are the two ways? Have I done one of them?
The two ways I know include.
- Modifying the titlebar (I need to check some of my older code on how to do this).
- Using NSWindow.stylemask to move the content of the window into the titlebar area, which is what Apple have recommended since 10.10.
It’s possible you may be using a 3rd way that I don’t know. As with Apple’s theres often many ways to accomplish the same thing (thankfully, because more often than not, one or two gets broken in OS “Updates”).
NSWindow.stylemask does not help here.
I used the ToolbarExample and added following code in the open Event of the Window
Const NSWindowStyleMaskTitled = 1
Const NSWindowStyleMaskFullSizeContentView = 32768
Self.styleMask = NSWindowStyleMaskFullSizeContentView + NSWindowStyleMaskTitled
WindowToolbar.AllowAutoDeactivate = False
and places some Canvases in the window.
I can actually draw below the ToolBar but it is below and not on top.
I used to code you placed some time ago in the Forum:
Public Sub styleMask(Extends w As Window, Assigns value As Integer)
Declare Sub mSetStyleMask Lib "Cocoa" selector "setStyleMask:" ( Ref As Integer, inValue As Integer )
mSetStyleMask( w.handle, value )
I dug out my old code for placing a control in the titlebar, and can see that it is what you’re doing.
The clue that I missed first time around, is to get to the titlebar of a window, you access the superview of the contentview.
I was able to get this
I created a toolbar with 3 items. Added it to the window. Then placed a pushbutton at 508 x 9.
In the open event of the window, I used this code (which relies on my current App kit).
NSWindowSetStyleMask( me.handle ) = setBit( NSWindowStyleMask( me.handle ), NSWindowStyleMaskFullSizeContentView, true )
NSToolbarSetBaselineSeparator( NSWindowToolbar( me.handle ) ) = false
NSWindowSetTitlebarAppearsTransparent( me.handle ) = true
I think the biggest difference, is how I apply the styleMask. With this code, I get the existing styleMask of the window, and then set the NSWindowStyleMaskFullSizeContentView flag on the value (the setBit method does a bitwise.bitOr).
Thanks for this, I’ll have a look into it soon. I’m on annual leave now
Is that like these mystical things I keep hearing about, vacation… holiday… weekend… Have no clue as to what those things are…