0

In swift 4 this fails

self.window.styleMask |= NSWindowStyleMask.fullSizeContentView

and I'd also like to undo

self.window.styleMask ^= NSWindowStyleMask.fullSizeContentView

as I would in objective-c

Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
slashlos
  • 913
  • 9
  • 17
  • Related: https://stackoverflow.com/questions/30761996/swift-2-0-binary-operator-cannot-be-applied-to-two-uiusernotificationtype – OptionSet is used since Swift 2. – Martin R Jul 04 '17 at 20:49
  • https://stackoverflow.com/a/29339315/2303865 – Leo Dabus Jul 06 '17 at 04:27

2 Answers2

0

In Swift, NSWindowStyleMask (in Swift 4, NSWindow.StyleMask) is OptionSet. You need to use methods defined for SetAlgebra.

Swift 4:

self.window!.styleMask.formUnion(NSWindow.StyleMask.fullSizeContentView)

self.window!.styleMask.formSymmetricDifference(NSWindow.StyleMask.fullSizeContentView)

The code below compiles both in Swift 3 & Swift 4:

self.window!.styleMask.formUnion(.fullSizeContentView)

self.window!.styleMask.formSymmetricDifference(.fullSizeContentView)
OOPer
  • 47,149
  • 6
  • 107
  • 142
  • 1
    Or `insert(.fullSizeContentView)` and (assuming that OP wants to remove, not to toggle) `remove(.fullSizeContentView)` – Martin R Jul 04 '17 at 20:46
  • Ah, yes I would want to insert/remote aka toggle. What odd though is that this new way swells the window to include the title, but removal causes it to shift and resize, with the net affect that the window moves down and gets shorter? I'd heard there was a sample which detailed how to use this. Perhaps that's all I need? – slashlos Jul 05 '17 at 01:30
0

This is ugly

self.window.styleMask = NSWindowStyleMask(rawValue: NSWindowStyleMask.fullSizeContentView.rawValue + panel.styleMask.rawValue)

seems to work? The net affect is the content shrinks (by title height) when it's toggled. So I might to back to what I had been using - .borderless

slashlos
  • 913
  • 9
  • 17