Xojo macOS “traffic light buttons” position

Posted this on the official forum but I’m not sure if @samRowlands hangs out there anymore and I’m pretty sure he knows how to do this…

I’m trying to achieve this look in an app:

I’m partially there using declares (thanks to a post from @samRowlands):

#If TargetCocoa Then
  Const NSFullSizeContentViewWindowMask = 32768
  Declare Function NSClassFromString Lib "Foundation" (aClassName As CFStringRef) As Ptr
  If NSClassFromString( "NSVisualEffectView" ) <> Nil Then
    Declare Sub setStyleMask Lib "AppKit" Selector "setStyleMask:" (handle As Ptr, value As Integer)
    Declare Function styleMask Lib "AppKit" Selector "styleMask" (handle As Ptr ) As Integer
    setStyleMask(Me.Handle, styleMask(Me.Handle) + NSFullSizeContentViewWindowMask)
    Declare Sub titlebarAppearsTransparent Lib "AppKit" Selector "setTitlebarAppearsTransparent:" (handle As Ptr, value As Boolean)
    titleBarAppearsTransparent(Me.Handle, True)
  End If

This is what I currently have:

Notice how the position of the traffic lights is closer to the top edge and left edge of the window than what I’m trying to achieve. Many apps in macOS (including Safari):

Screenshot 2023-07-15 at 09.06.17

position the traffic lights lower. How do I achieve this? How I currently have it means things just look too cluttered.

I think you’re using the wrong mask. In my app FileFreeze, I use NSWindowToolbarStyleUnified which the magic number value is 3.

This makes the minimum macOS required Big Sur.

1 Like

Not at work 'puter, so can’t check code, but @Tim solution seems to ring true with my tired brain.

Now, you can actually get the traffic light buttons and move 'em where ever you want. For my preferences windows, I hide the maximize button as it isn’t needed. Coda used to move 'em to a vertical orientation.

You can even be an asshole and change the order of the buttons, but I wouldn’t recommend this, unless you’re trying to frustrate people :slight_smile:

I don’t participate there very often anymore as I find it too frustrating.

1 Like

Thanks guys for the help.

Looks like I needed to add an empty ToolBar to the window (since I’m drawing my own controls up there) and use this code in Window.Opening():

Declare Sub SetToolbarStyle Lib "AppKit" Selector "setToolbarStyle:" (handle As Ptr, value As Integer)
SetToolbarStyle(Me.Handle, 4) ' 3 = Unified, 0 = Automatic works as well, 4 = unified compact.