Mac OSX在魔术触控板上检测手指时(即使在窗外)Swift

时间:2016-03-14 02:50:45

标签: swift macos touchesbegan

所以我的目标很简单。我正在尝试制作一个程序,用于检测手指放置在魔术触控板上的时间(最好不管它们当前在哪个窗口上)来运行一个过程....不幸的是事情进展不顺利。当用户点击窗口时我可以检测到触摸......一旦它在窗口外,所有的赌注都会关闭。有什么想法吗?

class ViewController: NSViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.acceptsTouchEvents = true
        //self.view.acceptsFirstResponder = true
        // Do any additional setup after loading the view.
    }
    var count = 0
    override func touchesBeganWithEvent(event: NSEvent) {
        print(count)
        count += 1
    }

    override var representedObject: AnyObject? {
        didSet {
        // Update the view, if already loaded.
        }
    }


}

0 个答案:

没有答案