如何在Mac OS X上将光标锁定到窗口的内部? [英] How can I lock the cursor to the inside of a window on Mac OS X?

查看:420
本文介绍了如何在Mac OS X上将光标锁定到窗口的内部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Mac OS X组合一个游戏,这涉及到很多快速动作和徘徊的鼠标光标。如果用户想要在窗口模式下播放,我很想锁定光标到窗口的内部,以避免在战斗的热量意外更改程序(显然,如果用户更改程序或命中逃脱暂停菜单。)

I'm trying to put together a game for Mac OS X which involves a lot of fast action and flinging around of the mouse cursor. If the user wants to play in windowed mode, I'd quite like to lock the cursor to the inside of the window to avoid accidentally changing programs in the heat of battle (obviously this will cancel itself if the user changes programs or hits escape for the pause menu.)

在Windows上,使用 ClipCursor()。我在Mac OS X上找不到一个等同的。有没有一个。

On Windows, this can be accomplished easily with ClipCursor(). I can't find an equivalent on Mac OS X. Is there one?

推荐答案

看看CGWarpMouseCursorPosition,CGAssociateMouseAndMouseCursorPosition和CGGetLastMouseDelta (ApplicationServices的一部分)。

Have a look at CGWarpMouseCursorPosition, CGAssociateMouseAndMouseCursorPosition and CGGetLastMouseDelta (part of ApplicationServices).

请参阅 http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html

这篇关于如何在Mac OS X上将光标锁定到窗口的内部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆