Window with no title

Hi, I’m using the following code in a windows open event to make it have no title bar:

Const AppKit = "AppKit"
Const NSWindowTitleHidden = 1
Const NSFullSizeContentViewWindowMask = 32768

Declare Sub titleVisibility Lib AppKit Selector "setTitleVisibility:" (handle As Integer, value As Integer)
titleVisibility(me.TrueWindow.Handle, NSWindowTitleHidden)

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.TrueWindow.Handle, styleMask(me.TrueWindow.Handle) + NSFullSizeContentViewWindowMask)

Declare Sub titlebarAppearsTransparent Lib AppKit Selector "setTitlebarAppearsTransparent:" (handle As Integer, value As Boolean)
titleBarAppearsTransparent(me.TrueWindow.Handle, True) 

However, when swapping from Light to Dark mode, the windows backgrounds to not update. Any help from someone in the know on this stuff would be greatly appreciated.

Many thanks, Dave.

Did you check the “Supports Dark Mode” in the Building Settings - Shared - Build?

Hi, yes. When the mode is changed, some elements switch, but the windows that’s have been made titleless, their background stays the same.

I just tested using Xojo 2020r2.1 with just your code above in open event and all changes as expected.
Do you have Has Background Color checked against the window?

No… strange. I’m on Big Sur.

10.14.6 for me. Do you get the app level appearance changed events?

Yes, all windows without this code in the open event change as you’d expect. Maybe it’s a Catalina thing.

Tested as universal build built on 10.14.6 with just above code in event on M1 Big Sur and 10.15.7 and both of them have the window’s background changing as you toggle light to dark mode in System Preferences. There must be something else kicking in. What type of window is it? my test is as document. Is there any other Api calls that could stop the events or custom rendering in the window paint event etc?

I’m using this code in a checkbox (Catalina):
Public Function TitleVisible(extends w as Window) as Boolean

#if TargetCocoa then
declare function titleVisibility lib “Cocoa” selector “titleVisibility” (WindowRef as integer) as NSWindowTitleVisibility

return titleVisibility(w.Handle) = NSWindowTitleVisibility.Visible


End Function

Public Sub TitleVisible(extends w as Window, assigns TitleVisible as Boolean)

#if TargetCocoa then
declare sub setTitleVisibility lib “Cocoa” selector “setTitleVisibility:” (WindowRef as integer, titleVisibility as NSWindowTitleVisibility )

if TitleVisible then
  setTitleVisibility w.Handle, NSWindowTitleVisibility.Visible
  setTitleVisibility w.Handle, NSWindowTitleVisibility.Hidden
end if

#pragma unused TitleVisible

End Sub

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