5

How can my menubar application achieve the same behaviours as 1Password or Dropbox:

  • clicking their menu bar icons or popovers does not steal focus, e.g. while I am in for example TextEdit and open 1Password/Dropbox, the blinking cursor disappears but the window itself does not go into the background, yet I can type into 1Password's text field.
  • even though they didn't take focus in the first place, they disappear when I click back into another application

I figured out how mouse over works in the Dropbox popover table view by using an NSTrackingArea with the options MouseEnteredAndExited, AssumeInside, and ActiveAlways.

I am trying to get the same behaviour to work in an NSPopover that opens from an NSStatusItem.

iMaddin
  • 982
  • 1
  • 14
  • 23

2 Answers2

2

I found a workaround for now. I am able to get the same behaviour by using non-activating NSPanel with a window level kCGPopUpMenuWindowLevelKey and I had to override canBecomeKeyWindow to return true.

Unfortunately I haven't found a way yet to get a NSPopover to behave this way since it's not a subclass of NSWindow.

iMaddin
  • 982
  • 1
  • 14
  • 23
1

To set the kind of behavior you are describing you use:

yourPopover.behavior = .transient

Pier
  • 10,298
  • 17
  • 67
  • 113