检测鼠标滚动
如何使用Pygame在Python中检测鼠标滚动滚动? 我已经创建了一种检测它的方法,但是它并没有给我任何信息,以了解我滚动鼠标的方式,并且在检测鼠标卷轴方面很糟糕,其中只有20中只有20中。
for event in pygame.event.get():
if event.type == pygame.MOUSEWHEEL:
print("Mouse Scroll Detected.")
我可以检测到鼠标卷轴的其他方法吗?
How do I detect Mouse scroll up and down in python using pygame?
I have created a way to detect it, but it doesn't give me any information about which way I scrolled the mouse as well as being terrible at detecting mouse scrolls where only 1 in 20 are getting detected.
for event in pygame.event.get():
if event.type == pygame.MOUSEWHEEL:
print("Mouse Scroll Detected.")
Any other ways I can detect mouse scrolls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
鼠标轮
事件对象具有x
和y
组件(请参阅pygame.event
模块)。这些组件表示旋转鼠标车轮的方向(用于水平和垂直轮):The
MOUSEWHEEL
event object hasx
andy
components (seepygame.event
module). These components indicate the direction in which the mouse wheel was rotated (for horizontal and vertical wheel):此后,使用
event.y == 1
进行向上滚动,event.y == -1
用于向下滚动After this, use
event.y == 1
for upward scroll, whileevent.y == -1
for downward scroll