import Cocoa
import Foundation
import AppKit
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
let myNSResponder = myResponder()
if NSApp.resignFirstResponder() {
if myNSResponder.acceptsFirstResponder {
println("Were accepting First Responder")
}else {
println("Not accepting First Responder")
}
}else {
println("NSApp Will Not Resign")
}
}
override var representedObject: AnyObject? {
didSet {
// Update the view, if already loaded.
}
}
}
class myResponder: NSResponder {
override func keyDown(theEvent: NSEvent) {
println("Key down ")
println(theEvent.description)
}
override func becomeFirstResponder() -> Bool {
return true
}
}// end of Class myResponder
Running program prints "Not accepting First Responder" and keypresses inputs are ignored giving me a system beep.