6
votes

NSPanel has a “Non activating” option for HUD Panels. I’d like to get that same functionality working on an NSWindow, i.e. I want the window to accept clicks but not take focus away from whatever the active app is (by this I mean the app that was active before clicking on the window activated my app—in this case Sketch).

I have tried creating an NSWindow subclass and setting canBecomeMainWindow and canBecomeKeyWindow to NO but that doesn’t seem to be working—I think because those settings only apply to windows within the same app.

What I’m trying to do here is prevent this flickering. I’m pretty sure this is doable as apps like Alfred seem to be doing it.

1
Hi Elliot and welcome to SO. When you ask a question try to insert snippets of code to demonstrate what you have done and where your problem lies. That will attract more users to study your question in detail and provide you with an answer.Patrick
Why not use an NSPanel? It is a window. Anything you can do with an NSWindow, you can also do with an NSPanel. There are a few methods/properties which change their default behavior, but you can use overrides to change those back.Ken Thomases
@KenThomases Thanks for the reply Ken. The problems I ran into with NSPanel were making the whole window light rather than dark and trying to set NSWindowTitleHidden. In my NSWindow I have these appearance settings and then a NSVisualEffectView set to light: self.window.styleMask = self.window.styleMask | NSFullSizeContentViewWindowMask; self.window.titleVisibility = NSWindowTitleHidden; self.window.titlebarAppearsTransparent = YES;Elliot Jackson
Good point @Patrick, thanks!Elliot Jackson
I haven't tested, but I expect it should work if you set the panel's appearance property (which it has by virtue of conforming to the NSAppearanceCustomization protocol) to [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight].Ken Thomases

1 Answers

0
votes

If anyone else comes across this, whilst not an exact answer to the question, you can indeed make NSPanel go light by adding a NSVisualEffectView to the view controller and setting it to light.