[Interest] Prevent tabbing of Qt application on macOS Sierra

René J.V. Bertin rjvbertin at gmail.com
Sat Dec 2 19:02:12 CET 2017


Hi,

I came across this >1 yo mail from Morten saying

> Create disableWindowTabbbing.mm with:
> 
> #import <AppKit/AppKit.h>
> 
> // Disables auto window tabbing where supported, otherwise a no-op.
> void disableWindowTabbing()
> {
> 
>     if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)]) {
>         NSWindow.allowsAutomaticWindowTabbing = NO;
>     }
> 
> }

This is an error I also make easily (and too often): checking for support for a given selector, and then invoking it directly instead of using that selector. This will fail in the linking stage with older Cocoa versions (pre 10.12 in this case). For the selector check to make sense you have to call [NSWindow setAllowsAutomaticWindowTabbing:NO] if it passes.

cf. https://developer.apple.com/library/content/releasenotes/AppKit/RN-AppKitOlderNotes/index.html "What should an application which already has support for tabbing do? - The application should explicitly opt-out of automatic window tabbing by calling [NSWindow setAllowsAutomaticWindowTabbing:NO]."

Cheers,
René



More information about the Interest mailing list