Pyglet 错误地将所有鼠标点击解释为左键点击
Pyglet incorrectly interpreting all mouse clicks as left clicks
我正在尝试在 ubuntu 20.04 上使用 pyglet,并且代码正在运行,除了我在按住左键的情况下指定了鼠标拖动的某些行为,(当中键或右键按下时有不同的行为)举行)但 mouse.LEFT
即使不是鼠标左键也是如此,我在下面插入了一个片段。
@window.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
if mouse.LEFT:
chart.x_offset += float(dx)
chart.y_offset += float(dy)
elif mouse.RIGHT:
chart.y_scale+=dy
感觉它可能是 bug/issue 在 Ubuntu 上解释鼠标信号,但我真的不知道,我是 pyglet 的新手。
感谢阅读
mouse.LEFT
和 mouse.RIGHT
是常量。您必须评估 buttons
参数中是否设置了特定位:
@window.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
if buttons & mouse.LEFT:
chart.x_offset += float(dx)
chart.y_offset += float(dy)
if buttons & mouse.RIGHT:
chart.y_scale += dy
我正在尝试在 ubuntu 20.04 上使用 pyglet,并且代码正在运行,除了我在按住左键的情况下指定了鼠标拖动的某些行为,(当中键或右键按下时有不同的行为)举行)但 mouse.LEFT
即使不是鼠标左键也是如此,我在下面插入了一个片段。
@window.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
if mouse.LEFT:
chart.x_offset += float(dx)
chart.y_offset += float(dy)
elif mouse.RIGHT:
chart.y_scale+=dy
感觉它可能是 bug/issue 在 Ubuntu 上解释鼠标信号,但我真的不知道,我是 pyglet 的新手。
感谢阅读
mouse.LEFT
和 mouse.RIGHT
是常量。您必须评估 buttons
参数中是否设置了特定位:
@window.event
def on_mouse_drag(x, y, dx, dy, buttons, modifiers):
if buttons & mouse.LEFT:
chart.x_offset += float(dx)
chart.y_offset += float(dy)
if buttons & mouse.RIGHT:
chart.y_scale += dy