我可以从非活动应用程序更改当前光标吗?
我有一个在后台运行的实用 Mac 应用程序(已启用LSUIElement
)。在某些情况下,该应用程序会显示一个带有多个按钮的菜单窗口。问题是,当我将鼠标悬停在该窗口上时,鼠标光标的行为仍然取决于其下方的应用程序 - 当菜单下有文本时,光标会更改为插入“工字梁”形状。
显然我更喜欢常规的指针箭头。经过一些黑客攻击后,我深入研究了 NSTrackingArea
和朋友,我可以检测到鼠标进入和鼠标退出事件。但是,当我尝试在鼠标输入时使用 NSCursor
更改当前光标时,没有任何反应。看起来机器拒绝从非活动应用程序更改光标,因为当我在鼠标输入事件之前激活应用程序时,光标会发生变化。
我不想仅仅为了更改光标而切换活动应用程序。有没有办法从非活动应用程序中摆弄光标?
I’ve got a utility Mac application that runs in the background (LSUIElement
enabled). Under some condition this application displays a menu window with several buttons. The problem is that when I hover over this window the mouse cursor still behaves according to the application beneath it – when there’s text under the menu, cursor changes to the insertion “I beam” shape.
Obviously I’d prefer a regular pointer arrow. I’ve dived into NSTrackingArea
and friends after a bit of hacking I can detect the mouse-enter and mouse-exit events. But when I try to change the current cursor using NSCursor
on mouse enter, nothing happens. Looks like the machine refuses to change cursor from an inactive application, because when I activate the application before the mouse-enter event, the cursor changes.
I don’t want to switch the active application just to change the cursor. Is there a way to fiddle with the cursor from an inactive application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于 OS X 的限制,我担心这是不可能的。
I'm affraid this is not possible due the OS X restrictions.