Issues with DGG.ENTER and DGG.EXIT


Just wondering if the following is intended behaviour:

Suppose you have two DirectFrames, A and B.
When DirectFrame A gets disabled while the mouse is over DirectFrame B, the DGG.EXIT and DGG.ENTER events will be thrown (directly after one another) for B (tested in Panda3D 1.6.2 and 1.7.2).

To see this in action, please run the following code and hold the mouse over the rightmost square (frame B); when you check the command console, you will see that “Exiting frame B.” and “Entering frame B.” are printed each time the leftmost frame (A) gets disabled.

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

fA = DirectFrame(
                  frameSize=(-.1, .1, -.1, .1),
                  pos=(-.75, 0., 0.),

fB = DirectFrame(
                  frameSize=(-.2, .2, -.2, .2),
                  pos=(.75, 0., 0.),

def notifyEnter(*args):

  print "Entering frame B."

def notifyExit(*args):

  print "Exiting frame B."
fB.bind(DGG.ENTER, notifyEnter)
fB.bind(DGG.EXIT, notifyExit)

def toggleState(task):

  if fA["state"] == DGG.NORMAL:
    print "\nDisabling frame A.\n"
    fA["state"] = DGG.DISABLED
    print "\nEnabling frame A.\n"
    fA["state"] = DGG.NORMAL

  return task.again

base.taskMgr.doMethodLater(2., toggleState, "toggle_state")


If it is supposed to be this way, I do believe it could cause problems in certain situations, like when entering or leaving B would be meant to deactivate A (which would in turn cause B to deactivate A once more, possibly leading to an unforeseen error).

So is this a bug or a case of “just don’t do that” :slight_smile: ?