• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Swift Keypress KeyDown NSResponder input function needed.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Swift Keypress KeyDown NSResponder input function needed.
      • From: Uli Kusterer <email@hidden>
    • Re: Swift Keypress KeyDown NSResponder input function needed.
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: removeObserver:forKeyPath:context: fails; but removeObserver:forKeyPath: works?!
  • Next by Date: Re: Swift Keypress KeyDown NSResponder input function needed.
  • Previous by thread: Re: Cocoa GUI app getting slower on MacPro or MacMini when disconnecting all screens
  • Next by thread: Re: Swift Keypress KeyDown NSResponder input function needed.
  • Index(es):
    • Date
    • Thread