Bug in DirectButton (not sure how to fix)

Greetings!

I’m still running Panda3D 1.2.3 and I don’t have a convenient copy of the latest head-build handy; my apologies if this issue has been fixed in a recent update.

We found an interesting issue concerning DirectButtons and window focus in Panda3D 1.2.3 for Windows. It starts with the following example code:

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.gui.DirectGui import *
from direct.interval.IntervalGlobal import *

base.openMainWindow(type="onscreen")

def buttonPressed(txt):
    print txt

myButton=DirectButton()
myButton.bind(B1PRESS,lambda x:buttonPressed('Doink!'))

myButton2=DirectButton()
myButton2.setX(.4)

myButton2.bind(B1PRESS,lambda x:buttonPressed('Plink!'))

run()

Running this small script will give you a Panda window with two buttons. To manifest the issue, do the following:

  1. Click and hold on the left button. “Doink!” is printed.
  2. While holding the mouse, press alt-tab to bring up the Windows program-selector. Continue holding the mouse button and the alt button down, but release tab.
  3. Move your cursor outside the Panda window.
  4. Release the mouse button and alt, which will kill the alt-tab window.

Panda is now in a state where if you click in the Panda window again, the click will be detected as a mousedown on “Doink!” (a second “Doink!” will be printed to the console), regardless of where the mousedown occurs. Obscure!

Is this a known issue that has been patched in a later version? If not, can anyone think of a workaround to force Panda to clear its notion of mousedown’d buttons when this order of operations occurs?

Thank you for your help!

Take care,
Mark