Python 中的鼠标悬停事件 (VPython)
视觉模块(VPython)中有类似scene.mouse.getclick的东西吗? 我需要它来进行翻转。 提前致谢。
编辑:我需要一个函数,当鼠标在特殊区域内移动而不单击时执行某些操作。
Is there something similar to scene.mouse.getclick in the visual module (VPython)?
I need it for a rollover.
Thanks in advance.
EDIT: I need a function for doing something when the mouse moves inside a special area without clicking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 mathmike 所提到的,您似乎可以使用 scene.mouse.pick 来获取当前位于鼠标下方的对象,至于“场景位置”,我认为 scene.mouse.pickpos 就是您想要的寻找 - 如果没有,您应该能够从全局鼠标位置计算它(通过 getEvent())。
否则,请考虑从 getEvent() 函数获取信息,并可能为自己编写一个事件循环。
As mentioned by mathmike, it would seem that you could use scene.mouse.pick to get the object that is currently under the mouse, and as for the 'scene-position', I think scene.mouse.pickpos is what you're looking for - if not, you should be able to calculate it from the global mouse position (through getEvent()).
Otherwise, look at getting your information from the getEvent() function, and possibly writing an event loop for yourself.
好吧,你的意思是此处中描述的 scene.mouse.getclick()文档?
我不知道你的意思
你在找什么?
Well, do you mean the scene.mouse.getclick() described here in the documentation?
I don't know what you mean by
What are you looking for?
scene.mouse.getclick 会告诉您上次单击鼠标时的位置。这与 scene.mouse.clicked 不同,后者告诉您是否有人单击。
没有相应的方法来查看某人是否将鼠标悬停在特定对象上。您可以做的一件事是使用 while 循环不断检查 scene.mouse.pick 以查看鼠标当前是否位于感兴趣的对象上。
scene.mouse.getclick will tell you where the mouse was when it was last clicked. This is different from scene.mouse.clicked which tells you if someone clicked.
There is no correspoding way to see if someone had their mouse over a particular object. One thing you can do is use a while loop that continually checks scene.mouse.pick to see if it is the mouse is currently over an object of interest.