I have a transparent NSWindow
that follows the user's screen everywhere he goes (the NSWindow
stays in front of every app, no matter what, even fullscreen apps).
In that NSWindow
i have a mouseDown
event that shows a popup. Let's say i'm on safari in fullscreen mode and i have my Window in front of it, i click on safari and i click again on my Window: nothing happens, the mouseDown doesn't occur. I have to click again so the mouseDown
event is triggered.
How can i force my NSWindow
to be always active so i don't have to click it 2x to trigger the mouseDown
when i click on a background app and click in my window again?
Thank you!
I'm not sure if this is exactly what you want (it's not quite a window wide setting), but, from the documentation:
By default, a mouse-down event in a window that isn’t the key window simply brings the window forward and makes it key; the event isn’t sent to the
NSView
object over which the mouse click occurs. TheNSView
can claim an initial mouse-down event, however, by overridingacceptsFirstMouse:
to returnYES
.The argument of this method is the mouse-down event that occurred in the non-key window, which the view object can examine to determine whether it wants to receive the mouse event and potentially become first responder. You want the default behavior of this method in, for example, a control that affects the selected object in a window.
However, in certain cases it’s appropriate to override this behavior, such as for controls that should receive
mouseDown:
messages even when the window is inactive. Examples of controls that support this click-through behavior are the title-bar buttons of a window.
Or you could try fiddling with
- (void)sendEvent:(NSEvent *)theEvent
and see if you can handle events in a custom way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With