In my menu bar app, I have a menu item which opens a window. The window opens in the front with the window behind it remaining the key window.
I can't get window.makeKey()
to work unless I run it after a breakpoint. I tried putting the line of code in different places in the window's life cycle and even put it in DispatchQueue.main.asyncAfter(deadline: execute:)
and it didn't work.
I have also tried using window.makeKeyAndOrderFront(sender:)
. The property window.canBecomeKey
is true.