Page 1 of 1

macOS Big Sur - Set ToolBar position to old style expanded

Posted: Wed Jan 20, 2021 10:38 pm
by mk-soft
On Big Sur is the position of ToolBar on TitleBar (Unified).

Simple way to change it ...

Code: Select all

;-TOP

; Fix ToolBar position on Big Sur to old style Expanded
; by mk-soft, 20.01.2021

#NSWindowToolbarStyleAutomatic = 0 ; Autmatic
#NSWindowToolbarStyleExpanded = 1  ; Top Left
#NSWindowToolbarStylePreference = 2; Top Center
#NSWindowToolbarStyleUnified = 3   ; TitleBar Large
#NSWindowToolbarStyleUnifiedCompact = 4 ; TitleBar without text

If OpenWindow(0, 0, 0, 450, 25, "ToolBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  ; Fix on Big Sur to old style expanded
  CocoaMessage(0, WindowID(0), "setToolbarStyle:", #NSWindowToolbarStyleExpanded)
    
  CreateImage(0,16,16)
  StartDrawing(ImageOutput(0))
  Box(0,0,16,16,RGB(255,255,255))
  Box(4,4,8,8,RGB(255,0,0))
  StopDrawing()
  CreateImage(1,16,16)
  StartDrawing(ImageOutput(1))
  Box(0,0,16,16,RGB(255,0,0))
  Box(4,4,8,8,RGB(255,255,255))
  StopDrawing()
  
  If CreateToolBar(0, WindowID(0), #PB_ToolBar_Text)
    ToolBarImageButton(0,ImageID(0), 0, "One")
    ToolBarImageButton(1,ImageID(1), 0, "Two")
  EndIf
  
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf
:wink: