I’m confused on how to make normal DirectFrames clickable. I’ve followed thread discourse.panda3d.org/viewtopic.php?t=2361 , but I still can’t seem to find the solution.
I’ve tried enabling [‘state’] to DGG.NORMAL, but it doesn’t seem to help. The only solution that I’ve find so far is to set pgFunc to PGButton but then I’m creating a button now and not an empty frame. My test code is below.
I create three frames using three different methods:
- using the most direct and naive view
def foo():
print “hello”
tframe = DirectFrame(pos=(-.5,0,0), frameSize=(-.2,.2,-.2,.2), state=DGG.NORMAL)
tframe.bind(DGG.B1CLICK, foo)
- Making my class
class zDirectFrame(DirectFrame):
def foo(self,event):
print “hello”
def __init__(self, *arg, **kw):
DirectFrame.__init__(self,*arg,**kw)
self.initialiseoptions(zDirectFrame)
self.bind(DGG.B1CLICK, self.foo)
tframe1 = zzDirectButton(pos=(0,0,0), frameSize=(-.2,.2,-.2,.2), state=DGG.NORMAL)
- Making a stripped down button class
class zzDirectButton(DirectFrame):
def foo(self,event):
print “hello”
def __init__(self, parent = None, **kw):
optiondefs = (
('pgFunc', PGButton, None),
('numStates', 4, None),
)
self.defineoptions(kw, optiondefs)
DirectFrame.__init__(self, parent)
self.initialiseoptions(zzDirectButton)
self.bind(DGG.B1CLICK, self.foo)
tframe2 = zDirectFrame(pos=(0.5,0,0), frameSize=(-.2,.2,-.2,.2), state=DGG.NORMAL)
Of the three frames that are created, only last method is clickable, but then its a button so no surprise Can anybody spot my error?
Thanks.