Why do I manually create NSApp without icons that can’t receive the keyboard accordingly?
that’s because the ActivationPolicy (display Policy) is not set
ActivationPolicy (application display Policy)
There are three kinds of application display strategies
1, NSApplicationActivationPolicyRegular regular
This approach is the default option when using Info.plist bundle development (bundled apps).
effect: the taskbar (Dock) displays the application icons, and all the normal operations are displayed on the menu bar (menu, bar), and so on.
can be activated (corresponding to the keyboard and accepted by the mouse)
PolicyRegular normal mode
2, NSApplicationActivationPolicyAccessory auxiliary
No (Dock) on the taskbar icon, no menu bar (menu bar)
can be activated (accept, accept the corresponding keyboard mouse)
in Info.plist by LSUIElement=1 set the display strategy of
PolicyAccessory” are gone
3, NSApplicationActivationPolicyProhibited banned
This approach is the default option in unbundled apps.
does not have icons on the taskbar (Dock). There is no menu bar (menu bar). There may be no window (Window), and there is a window that will not be activated.
cannot be activated (not accepted by the keyboard, corresponding to the mouse)
PolicyProhibited” are gone