I’m making a new button class that has support for onMouseOver, onMouseOff, and onRelease handlers (using bind() and accept()). However, instances of the new class don’t appear on screen, even though they’re in the scenegraph. (I have tried explicitly parenting them and explicitly calling show() on them, neither of which worked.)
Just to check, I tried making a dummy version of the class with only pass as the body (i.e. any calls to it will be passed up to DirectButton), and that did not display.
I tried the same thing with OnscreenText, and the dummy derived class worked fine. With DirectLabel, the dummy derived class also does not display.
What parameters are you passing to the constructor? Have you tried passing the same parameters to an ordinary DirectButton, to see if you can see that object? Depending on the parameters you pass, you may be creating an empty button.
I had the same problem and think I have a solution. Maybe it is of use to others in the future. Call this in the constructor of your Direct* child class, say “MyClass”:
That’s what I thought, but it doesn’t work. You indeed need to call DirectButton’s constructor and self.initialiseoptions(MyClass), even if you don’t define any new options.