Friday, December 11, 2020


Tags

macOS-Big-Sur-icon

Preparing your Xojo made Mac App for macOS Big Sur

Part 5 - Big Sur's Big Toolbar Styles

Friday, December 11, 2020 - Sam Rowlands

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

Automatic

Big Sur automatic toolbar style #if targetMacOS and targetDesktop then if NSObjectRespondsToSelector( self.handle, NSSelectorFromString(

"setToolbarStyle:"

) ) then NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.automatic end if #endIf

Expanded

Big Sur expanded toolbar example #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.

Preference

Big Sur preferences toolbar design #if targetMacOS and targetDesktop then if NSObjectRespondsToSelector( self.handle, NSSelectorFromString(

"setToolbarStyle:"

) ) then NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.preference end if #endIf

Unified

Big Sur unified toolbar style #if targetMacOS and targetDesktop then if NSObjectRespondsToSelector( self.handle, NSSelectorFromString(

"setToolbarStyle:"

) ) then NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.unified end if #endIf

Unified Compact

Big Sur unified compact toolbar style #if targetMacOS and targetDesktop then if NSObjectRespondsToSelector( self.handle, NSSelectorFromString(

"setToolbarStyle:"

) ) then NSWindowSetToolbarStyle( self.handle ) = NSWindowToolbarStyleValue.unfiedCompact end if #endIf

Unified - Icon Only

Big Sur unified toolbar style, icon only #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

Unified - Text Labels Only

Big Sur unified toolbar style, with the window title hidden #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

Unified - No window title

Big Sur unified toolbar style, with the window title hidden

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