How to partially disable resize properties of NSWindow?

228 Views Asked by At

enter image description here

In one of my NSWindow (shown in above image) I want to disable split window properties i.e. "Tile Window to Left of Screen" & "Tile Window to Right of Screen".

My existing Window Controller code is provide below:

class VideoWindowController: NSWindowController, NSWindowDelegate {

    override func windowDidLoad() {
        super.windowDidLoad()

        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.

        self.window?.titlebarAppearsTransparent = false
        self.window?.backgroundColor = NSColor.init(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)
        self.window?.styleMask = NSWindow.StyleMask(rawValue: NSWindow.StyleMask.resizable.rawValue | NSWindow.StyleMask.titled.rawValue | NSWindow.StyleMask.closable.rawValue |  NSWindow.StyleMask.miniaturizable.rawValue)            
    }

    @objc func setNonResizableStyle() {
        self.window?.titlebarAppearsTransparent = false
        self.window?.styleMask = NSWindow.StyleMask(rawValue: NSWindow.StyleMask.titled.rawValue | NSWindow.StyleMask.miniaturizable.rawValue)
        self.window?.level = .floating
    }

    @objc func setResizableStyle() {
        self.window?.titlebarAppearsTransparent = false
           self.window?.styleMask = NSWindow.StyleMask(rawValue: NSWindow.StyleMask.resizable.rawValue | NSWindow.StyleMask.titled.rawValue | NSWindow.StyleMask.closable.rawValue |  NSWindow.StyleMask.miniaturizable.rawValue)
        self.window?.level = .normal

       }
}
1

There are 1 best solutions below

0
Ely On BEST ANSWER

You must change the collectionBehavior of your NSWindow object to disable certain split window features:

window?.collectionBehavior = [.fullScreenDisallowsTiling]

More info can be found here: https://developer.apple.com/documentation/appkit/nswindow/collectionbehavior