0

I want to achieve a certain window behavior for a macOS app. I subclassed NSWindow to be able to add additional properties. So far, it works well with almost all requirements (dragging it, clicking buttons) while preserving the core requirement of not making the currently active app losing focus. What does not work is making the window's UI elements react to mouse-hover events.

Requirements:

  • ☑️ Don't activate the app when showing the window → _setPreventsActivation:true
  • ☑️ Prevent activation of the app when interacting with the window (click/drag) → _setPreventsActivation:true
  • ﹖Make the window react to mouse hover events over interactive UI elements without activating the app

An example of an application that does very much what I intend to do (UX-wise) is 1Password. Here is a short clip: An animated GIF showing 1Password UX

Can someone explain what they likely do to make their window behave this way?

  • Is the window in the GIF a background window? Where does the keyboard input go? Is the question how to monitor global mouse events, how to recognize mouse-hover or how to implement a floating window? – Willeke Sep 21 '22 at 08:23
  • Hey @Willeke, it is not a background window. Or how would I know? It "feels" exactly how spotlight would react. - The keyboard input should continue to go the active window ("should not take key"). In the shown example, 1Pass obviously takes key. - The question is which window properties are needed / which (private?) macOS APIs to invoke on an `NSWindow` in order to achieve the listed requirements. – Adrian Hupka Sep 21 '22 at 15:09
  • Does this answer your question? [How to show a window without stealing focus on macOS?](https://stackoverflow.com/questions/46023769/how-to-show-a-window-without-stealing-focus-on-macos) – Willeke Sep 22 '22 at 07:44
  • Unfortunately not, I had already been there - and could replicate the feature. What's missing is how to have these windows still taking hover events. – Adrian Hupka Sep 22 '22 at 12:16
  • SwiftUI or AppKit? – Willeke Sep 23 '22 at 09:14

0 Answers0