In the last article we saw how to use App Wrapper 4 to enable the new macOS 11 Big Sur GUI features, including the unified toolbar and funky slider.
Updated Dec 11th 2020 to show a more complete difference between the styles and a few other options.
Once you have the Ohanaware App Kit configured in your Xojo project and App Wrapper 4 configured, simply copy and paste the code into the "Open" event of the window. This is window specific, so if you want all your windows adopting the same style, you'll need to do it for each window.
To see an overview of the differences between macOS 10.16 and macOS 11.0, read macOS 11.0 or 10.16 - Spot the difference
#if targetMacOS and targetDesktop then
if NSObjectRespondsToSelector( self.handle, NSSelectorFromString( "setToolbarStyle:"
) ) then
NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.automatic
end if
#endIf
#if targetMacOS and targetDesktop then
if NSObjectRespondsToSelector( self.handle, NSSelectorFromString( "setToolbarStyle:"
) ) then
NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.expanded
end if
#endIf
The layout here is what we'd expect on macOS Catalina or below and you can see that the "Flexible Space" items still work, but only in a couple of situations.
#if targetMacOS and targetDesktop then
if NSObjectRespondsToSelector( self.handle, NSSelectorFromString( "setToolbarStyle:"
) ) then
NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.preference
end if
#endIf
#if targetMacOS and targetDesktop then
if NSObjectRespondsToSelector( self.handle, NSSelectorFromString( "setToolbarStyle:"
) ) then
NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.unified
end if
#endIf
#if targetMacOS and targetDesktop then
if NSObjectRespondsToSelector( self.handle, NSSelectorFromString( "setToolbarStyle:"
) ) then
NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.unfiedCompact
end if
#endIf
#if targetMacOS and targetDesktop then
if NSObjectRespondsToSelector( self.handle, NSSelectorFromString( "setToolbarStyle:"
) ) then
NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.unfied
end if
NSToolbarSetDisplayMode( NSWindowToolbar( self.handle ) ) = NSToolbarDisplayModeValue.iconOnly
#endIf
#if targetMacOS and targetDesktop then
if NSObjectRespondsToSelector( self.handle, NSSelectorFromString( "setToolbarStyle:"
) ) then
NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.unfied
end if
NSToolbarSetDisplayMode( NSWindowToolbar( self.handle ) ) = NSToolbarDisplayModeValue.labelOnly
#endIf
This was a "What If..." moment... Hey at least the flexible space items work again.
#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