user187676
user187676

Reputation:

NSWindow child window close on parent click

I need to implement a custom popover (cannot use NSPopover). Its all working fine, but I also need to implement that the popover closes itself when the user clicks somewhere in the parent window.

What's the best way to implement this, resp. how could this be implemented without subclassing the parent window?

Upvotes: 1

Views: 1004

Answers (1)

hamstergene
hamstergene

Reputation: 24429

Make the popover key window when showing it, and use NSWindowDidResignKeyNotification (or the delegate method) to close when it resigns that status (which happens when user makes some other window active). Closing whenever the parent window is closed is also a good idea (NSWindowWillCloseNotification).

Upvotes: 1

Related Questions