NSPanel borderless but always on top

372 Views Asked by At

I am trying to make a NSPanel that looks like this

borderless

This is initialized like that

        let panel1 = NSPanel(contentRect: frame1,
                             styleMask: [.borderless],
                             backing: .buffered,
                             defer: true)

The thing is, when I click anywhere on the screen outside of that panel, it disappears. Only when i click on the application icon again, it comes to foreground.

With the following implementation I am getting the panel to stick on top, but there its having a border

        let panel1 = NSPanel(contentRect: frame1,
                             styleMask: [.borderless, .nonactivatingPanel],
                             backing: .buffered,
                             defer: true)

The border (few black pixels) looks like this but is always on top.

border

The question

How can I have it borderless (like the first image) but always on top (like the 2nd image).

Notes

  • Both variants have level = .mainMenu
  • Both variants have collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
1

There are 1 best solutions below

0
Curious Fishel On

I know it's been a while, but for whoever is struggling, simply add hasShadow = false that will do the trick.