当前位置: 动力学知识库 > 问答 > 编程问答 >

osx - Getting mouse position in entire screen Mac OS X

问题描述:

I'm writing a program that needs to get the mouse position in the screen, (not just my view). I need to continuously update variables xPos and yPos. I've heard about subclassing nsview and adding mouseDidMove, but it is never called. (Yes, I set my window view to my custom view.) How can I do this?

网友答案:

You need to set the NSWindow which contains the view to window.acceptMouseMovedEvents = yes. Also if you're just looking for mouse position in the screen consider NSEvent.mouseLocation

分享给朋友:
您可能感兴趣的文章:
随机阅读: