There will be no error with the code above but the text will not render.
I figured out that the text is not appearing because I’m repareting a Gui element to a NodePath which I reparent to a Gui.
Well, to avoid this, I suppose I just need to replace NodePath by the correct father but what’s the father of directGui objects ?
I thought it was render2d but it’s not working!
So, you want to subclass from DirectGui and make your own kind of object? You can subclass from any of the existing DirectGui classes, for instance DirectFrame, which is probably the minimal functionality. Note that you also have to call initialiseoptions() when you do this. See discourse.panda3d.org/viewtopic.php?t=2495 .
DirectFrame it was
So now, I can create my own type of button, frames etc… Amazing!
I tried with and without initialiseoptions() and both did work. For this, I’ll blindly trust you and always put it in the declarations but this brings the following:
If in a near futur, I’ll need to create a class from an other object. How can I know if there is a function that I’m suppose to call additionnaly to init ?
And one last question:
Is it possible to generate an event when the mouse rollover a button ?
I tried to replace the text “rolling over” by a function that perform my desired actions and then return a string but KO!
You have to read the documentation for the class you’re inheriting from. Usually, you don’t need to do anything special; the DirectGui classes are unusual in this requirement.