Toolbar difference between Xojo 2021R1 and 2020R2.1

Compiled with Xojo 2020R2.1

Screenshot 2021-03-31 at 21.04.20

Compiled with Xojo 2021R1

Screenshot 2021-03-31 at 21.05.24

How to fix this?
Maybe related to NSWindowToolbarStyleExpanded ?

Do you run it on a M1 Mac? I always get the result as on the second screenshot with 2021r1.

No, MBP Intel

Can you make a sample project please to compare?

New project → add Open event in Window → insert code below → add toolbar → compile.

declare function NSClassFromString lib "Foundation" (aClassName as CFStringRef) as Ptr
if NSClassFromString( "NSVisualEffectView" ) <> nil then
  declare sub titleVisibility lib "AppKit" selector "setTitleVisibility:" ( handle as integer, value as integer )
  const NSWindowTitleHidden = 1
  titleVisibility( me.handle, NSWindowTitleHidden )
end if

const NSFullSizeContentViewWindowMask = 32768
if NSClassFromString( "NSVisualEffectView" ) <> nil then
  declare sub setStyleMask lib "AppKit" selector "setStyleMask:" ( handle as integer, value as integer )
  declare function styleMask lib "AppKit" selector "styleMask" ( handle as integer ) as integer
  setStyleMask( me.handle, styleMask( me.handle ) + NSFullSizeContentViewWindowMask )
  declare sub titlebarAppearsTransparent lib "AppKit" selector "setTitlebarAppearsTransparent:" ( handle as integer, value as boolean )
  titleBarAppearsTransparent( me.handle, true )
end if
1 Like

Hmmm, maybe related to the new macOS 11 SDK they using in 2021r1? @Greg_O_Lone

This is absolutely what it is. I don’t have the “fix” offhand, but the shorter style is the new expected design. My advice is to embrace it rather than fight it, but I completely understand needing to find a solution to buy some time in case designs need to be updated.

I probably need to set the NSWindow to NSWindowToolbarStyleUnified (which was the default in previous Xojo versions).
The newer Xojo forces it to NSWindowToolbarStyleExpanded which is imo wrong to do.

This isn’t Xojo’s change. They’re just using the newer SDK which uses the newer toolbar style.

According to the cheat sheet I prepared earlier.

https://www.ohanaware.com/blog/202049/Preparing-your-Xojo-made-Mac-App-for-macOS-Big-Sur-Part-5.html

You want to use the unified toolbar style with no window title.

#if targetMacOS and targetDesktop then
  if NSObjectRespondsToSelector( self.handle, NSSelectorFromString( "setToolbarStyle:" ) ) then
    NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.unfied
  end if
  NSWindowSetTitleVisibility( self.handle ) = NSWindowTitleVisibilityValue.hidden
#endIf
3 Likes

This isn’t just about the updated SDK, Xojo also made a change to force the toolbar style. It’s a private case but from the release notes:

63414 Framework » macOS Toolbars on macOS Big Sur are now in the Expanded style by default to better match previous behavior.

1 Like

It should also be noted that the Expanded toolbar is the only one that supports 32x32 icons and Flexible Spaces. The change was made so you could open an older project and have it work just as it previously had without the requirement of a Declare.

So does that mean forcing the expanded toolbar isn’t working, since the original issue is about it using compact in 2021r1?

That doesn’t seem to be the case. The pics in the first post show Compact in 2020r2.1 and Expanded in 2021r1.

Whoops. Yeah, you’re right. I read the versions backwards.

That’s what I was saying in te first place but most just didn’t believe me (or didn’t understand the problem and just blamed it on Big Sur).
Anyhow, you can have the ‘old’ behaviour if you add this in the window open event - if you have the MBS plugins.

me.NSWindowMBS.toolbarStyle= 4 (which is unifiedCompact)

https://developer.apple.com/documentation/appkit/nswindow/toolbarstyle

Or the declare:

Declare Sub toolbarStyle Lib "AppKit" Selector "setToolbarStyle:" (handle As Ptr, value As Integer)
toolbarStyle(Me.Handle, 4)
2 Likes

@Greg_O_Lone, it still looks like Xojo’s NSWindow Implementation is buggy. Please watch the attached Screenshots. First, Window Design in the IDE, second the running App. The PushButton and Label are Locked to the Bottom of the Window. If I run the App, there will be an offset for all Controls at the bottom regardless of whether they are locked.

The workaround to set the following code in the Window Open-Event does not help!

Sample Project Download

Self.Height = Self.Height
' or
Self.Height = Self.Height + MyToolbar.Height


Does it help if you add 1 to the height and then remove 1 from the height, basically forcing the window to recalculate the layout.

“Auto-layout is hard” is a common meme when developing for Apple platforms in recent years, not just in Xojo.

We are aware of this issue when not using the Expanded toolbar. If you are using declares to change the toolbar style, you will also need to adjust the window height.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.