cocoa - How do I reliably get windowDidBecomeMain and windowDidResignMain events? -


i have view controller in want receive windowdidbecomemain , windowdidresignmain events.

in viewwillapear() set window delegate self.

view.window?.delegate = self 

i have added extension view controller conforms nswindowdelegate , have implemented both methods in thus:

extension customerlistviewcontroller: nswindowdelegate {   func windowdidbecomemain(_ notification: notification)   {     print("customer list did become main")   }    func windowdidresignmain(_ notification: notification)   {     print("customer list did resign main")   } } 

this not initial window. opened via menu item window controller show segue.

when window first opened via menu item, not receive windowdidbecomemain.

when click window does receive windowdidresignmain.

if click newly opened window receive windowdidbecomemain , point on.

i suspect need set window delegate @ different point don't have clue so, if is case.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -