You can’t observe the onActiveSpace
property because SkyLight does not support that feature. If you really want to observe it, you can either observe the private notification named _NSWindowDidChangeWindowNumber
or override -[NSWindow _commonAwake]
.
But I want to ask: why? The onActiveSpace
property indicates that NSWindow has created an NSCGSWindow and that it is connected to the WindowServer’s space. If it’s a tabbed window and that tab is not selected, it will return NO. Why do you want to observe this? If you initialized NSWindow with defer:YES
, NSWindow will be on the space immediately.
If you want to determine whether a window is visible to the user, you need to use the occlusionState
and observe the NSApplicationDidChangeOcclusionStateNotification
.