OS: Windows 10
Panda version: 1.10.12-x64
Mouse mode is default: absolute.
Okay so imagine you have camera or something accepting mouse input, and for one function (such as rotate, zoom, pan), you need to click and drag mouse1 and mouse3 at the same time.
Even for Panda’s default mouse controls, mouse1 and mouse3 clicked together and the mouse dragged is what is used for rotating the camera.
The issue is, if you do that in Windows, and drag the mouse outside of the window, and release the two buttons, only the first one released will be registered. So, if you move your mouse cursor into the window, Panda will think you have the last mouse button you have released last still being held down. So for example, with stock camera controls, if you click mouse1 and mouse3 and drag them outside the window, then release mouse1 first, then if you move back into the window Panda will think you still have mouse3 held down and will trigger zooming when you move the cursor back into the window. Similarly, if you release mouse3 first, then if you move back into the window Panda will think you still have mouse1 held down and will trigger panning.
The issue also happens if you create your own mouse input with base.accept() and do the same.
Here’s a code snippet to replicate the issue and see how the base.accept() does not get triggered for both buttons if you do the above mentioned steps:
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
base = ShowBase()
def mouse1UpFunc(): print("mouse 1 is up")
def mouse2UpFunc(): print("mouse 2 is up")
def mouse3UpFunc(): print("mouse 3 is up")
base.accept("mouse1-up", mouse1UpFunc)
base.accept("mouse2-up", mouse2UpFunc)
base.accept("mouse3-up", mouse3UpFunc)
base.run()
I haven’t tested every other key on the keyboard, but initial impression is it is only an issue with the mouse keys.
The issue is even worse if you click two mouse buttons, drag the cursor outside the window, release them, then click one of the buttons outside of the window couple of times before moving the cursor into the Panda window again. Panda will simply freeze in few seconds and crash. This is with the above sample code and I’ve replicated the crash 5 times before posting this. I haven’t been able to identify the exact button clicking pattern which leads to the freezing. It may be only caused when you click on the buttons on another window such as the Windows console rather than on the desktop,where right click opens a menu, but not sure, crash occurance seems kind of random.
I’m not reporting this as a bug as I’m not sure if it’s a bug in Panda or a weird way how Windows mouse input works.
A workaround seems to be checking if the mouse is outside the window with base.mouseWatcherNode.has_mouse()
and manually doing base.ignore("mouse1")
, base.ignore("mouse2")
, base.ignore("mouse3")
, base.ignore("mouse1-up")
, base.ignore("mouse2-up")
, base.ignore("mouse3-up")
and re-enabling them when the mouse cursor is again detected to be inside the window.