Swift Keypress KeyDown NSResponder input function needed.
Swift Keypress KeyDown NSResponder input function needed.
- Subject: Swift Keypress KeyDown NSResponder input function needed.
- From: Mutlu Qwerty <email@hidden>
- Date: Wed, 11 Mar 2015 20:09:30 -0400
- Importance: Normal
Hello List:My Sudoku Puzzle game needs to get keyboard digits, 1 thru 9, and the arrow keys as input.I have read Handling Key Events in the Cocoa Event Handling Guide and produced this codewhich compiles ok and runs giving me system beeps indication that my keyDown function is not working as I expected. I searched the Archives also.import Cocoa
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.nextResponder = super.nextResponder //insert self into the Responder chain
}
override var representedObject: AnyObject? {
didSet {
}
}
override var acceptsFirstResponder: Bool {
return true
}
override func keyDown(theEvent: NSEvent) {
println("key down is \(theEvent.description)") //system console should be displaying the keypress
}
override func becomeFirstResponder() -> Bool {
return true
}
override func resignFirstResponder() -> Bool {
return true
}
}//--------- Thomas ------
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden