I have a SceneKit view that works very fine. its view controller gets and manages the key down events in an override of keyDown(with event: NSEvent).
But, as soon as I add a SceneKit overlay like this:
let skScene = MySKScene(fileNamed: "Level1.scnassets/3_overlay.sks")!
scnView.overlaySKScene = skScene
skScene.isUserInteractionEnabled = false
The SKScene gets all the key down events (Level1.scnassets/3_overlay.sks is just an empty scene).
Worse, I did trace the events like this:
class MySKScene: SKScene {
public override func keyDown(with event: NSEvent) {
print("I reach here !")
print(" isUserInteractionEnabled: \(self.isUserInteractionEnabled)")
func printResponderChain(indent: String, resp: NSResponder) {
print(indent + "type: \(type(of: resp))")
if let father = self.nextResponder {
printResponderChain(indent: indent + " ", resp: father)
}
}
printResponderChain(indent: "", resp: self)
}
}
I get this:
I reach here !
isUserInteractionEnabled: false
type: MySKScene
So the SKScene tells me at the same time:
- the
keyDownmethod is called isUserInteractionEnabledis false- the responder chain is only made of the SKScene itself
How to fully disable the SKScene ?