Xojo 2017r3, macOS 10.12.6 Sierra
I have a project that opens a window at start-up (no surprise there). This window stays open for the duration of the apps life. When I open a new window (either from the MainMenu or from a button on the original window, it opens as a tab to the original window instead of a separate new widow. I can drag it out to a separate window but I don’t want it to open as a tab in the fist place.
What’s going on?
What’s the code that opens the window?
using statement window.show
and the window type is document
Neat. Curious about this too so I can do it intentionally!
I’m sure there will be times I want it to do this also - just not right now.
Something has changed, my app didn’t use to do this.
OSX does this by default after 10.12
This is the code I use to stop it. Its taken from another forum user… probably Sam Rowlands…
[code] if bAllowTabs = false then
dim theOS as string
theOS = SystemInformationMBS.OSVersionString
theOS = replace(theOS,“Mac”,"")
theOS = replace(theOS,“OS”,"")
theOS = replace(theOS,“X”,"")
theOS = trim(theOS)
//theOS = left(theOS,instr(theOS," ")-1)
if theOS >= "10.12" then
declare function objc_getClass lib "libobjc.dylib" ( name as CString ) as ptr
dim nsWindowClass as ptr = objc_getClass( "NSWindow" )
declare sub AllowTabGrouping lib "AppKit"selector "setAllowsAutomaticWindowTabbing:" ( classPtr as Ptr , enableDisable as Boolean )
AllowTabGrouping( nsWindowClass, false )
Wait, that won’t open a new window, it will bring the existing window to the front. Did you mean something like this?
dim w as new Window1
Jeff, I haven’t seen this and I primarily work in MacOS, so there has to be some trigger. Any idea what that might be?
I just found that I can reproduce it in full-screen mode.
- Start the app.
- Got to full screen.
- Open a new window.
I still can’t do it when not in full-screen.
Ah HA! I can’t do it by holding down the option key while opening the new window. This suggests a system preference somewhere that reverses that behavior.
…and it’s in System Preferences -> Dock. If I had ever known that, I had forgotten it, but it’s set to “In Full Screen Only” here.
Have you considered making the window a ContainerControl and then either embed it in a new window or in a new tab depending on the user’s need?
Scratch that - I missed the process you mentioned. I ran into this with the Terminal and it was a setting there.
The reason I turn it off is that when a Xojo window produces a tab, we dont get a resize event.
Thus any status bar style control or button near the bottom of the document window is obscured until an actual resize occurs
// Disable auto tabbing in Sierra
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)
goes in APP.OPEN
sorry, I forgot to make note of who I got this from
[quote=396654:@Jeff Tullin]The reason I turn it off is that when a Xojo window produces a tab, we dont get a resize event.
Thus any status bar style control or button near the bottom of the document window is obscured until an actual resize occurs[/quote]
More than that, Xojo doesn’t even realize anything has changed until you do a resize. Width and Height remain unchanged after the tab is added and controls that are pinned to the bottom of the window don’t slide or resize.
Is there Feedback for this?
It was the Dock tab preference in System Preferences. Apparently after the last update it got changed to Always. Put it to Manual and all is back to normal…