Double titles on Mac Document windows

In recent times, one of my Mac Apps has started having ‘two titles’

I cannot work out why this happens, or how to stop it.
The second one was showing as a full path when I have code to try to set the setTitleWithRepresentedFilename

I got tabed windows (two of my windows inside one)…

But that is the first time I saw that one. 🥹

I can more or less understand when there are are two document windows
OSX is (trying) to be helpful. I hate it, however

But this happens even when there is only one document window open… there is nothing to tab to…

I could cope with tabbing when it happens, if only Xojo would provide a resized event.
It doesn’t, so the bottom 8mm of my windows disappear when this happens, unless I manually resize afterwards. (Thats awful!)

For Window and DesktopWindow, there is a Resized event.

For Window and DesktopWindow, there is a Resized event.

Which does not fire if an existing window is moved into a tab configuration.

Specifically, I have a status bar at the bottom of a document window
while the window stands alone, it is visible.

If a second window is opened, both windows are tabbed, and the available height is smaller than it was before.
The first window does not get a resized event, and believes it has not changed.
The status bar lies outside/ is drawn below the available area.
If I resize the grouped window, all child windows get a resized event.

This call should stop it happening, but doesn’t

verified but ignored(?) 4 years ago.

Xojo doesn’t support Apple’s tabbed windows at the moment so I wouldn’t expect it to handle adjusting the size correctly either, but that’s exactly what this is. When tabs are enabled for your app, each tab also has its own name… even if there’s only one.

1 Like

Could you show the code that includes this declare?

Sorry… after reading a little more, it looks like you need

Declare Sub SetTabbingMode Lib "AppKit" selector "setTabbingMode:" (obj as Ptr, value as integer)

SetTabbingMode(w.handle, 2) // 2 = Disabled

If you’re using API 1, you’ll need to change obj as Ptr to obj as Integer

Thanks Greg.
I have used this, and what seems to be the same call from MBS plugins, in the
Open event of my window

and both before and after the super.consructor call in a subclass of the same window

In all cases, the first window opened has the double title, the second and third windows dont.

System preferences are set to ‘never’

The setAllowsAutomaticWindowTabbing code is:

  Declare Function NSClassFromString Lib "Cocoa" (s As CFStringRef) As Ptr
  Declare Function NSSelectorFromString Lib "Cocoa" (s As CFStringRef) As Ptr
  Declare Sub setAllowsAutomaticWindowTabbing Lib "Cocoa" selector "setAllowsAutomaticWindowTabbing:" (cls As Ptr, ena As Boolean)
  Declare Function respondsToSelector Lib "Cocoa" selector "respondsToSelector:" (p As Ptr, sel As Ptr) As Boolean
  Dim nswCls As Ptr = NSClassFromString ("NSWindow")
  If respondsToSelector (nswCls, NSSelectorFromString ("setAllowsAutomaticWindowTabbing:")) Then
    setAllowsAutomaticWindowTabbing (nswCls, False)
  End If

Have you tried the setTabbingMode call I created there? The handle should be the handle of the window.

I have.
It appears equivalent to the MBS call I also tried

    dim n as NSWindowMBS = self.NSWindowMBS 
    n.tabbingMode = n.NSWindowTabbingModeDisallowed 

It is now randomly happening on the first window only.
I’ll try restarting the Mac.

I note the request for Xojo to handle the sizing after tabbing occurs actually dates back to 2016.
I guess it will never be addressed.

1 Like

It’s happening on a single Mac only?

Some customers too, but at least THIS one I can recreate on my own machine.

1 Like

There is a setting in System Preferences > General, for Prefer Tabs, which is typically set to Full Screen. Other options are Never and Always.

If Always is set and New open document window instruction gets routed to a New tab in the current Document window (unless your flags are set as above). Equally, if you go to full screen and create a new window it ends up in a tab if “Full Screen” option is chosen. When you come out of full screen the tabs remain. I’ve not seen a Tab on a single document in a window, that is unusual.

We do this during the initialisation of our app and before any windows open when running on High Sierra and later and have not had any reports of tabs appearing:

NSWindowMBS.allowsAutomaticWindowTabbing = False

Mine set to Never

We do this during the initialisation of our app

Me too.
Which is why this ‘one window showing a tab title even when there are no other tabs’ is so odd.

Hasn’t happened since a restart… may now remain a mystery forever.

Xojo should still fix the sizing messages.