Hit detection on DirectButtons

Hi all!

I have a DirectButton that I’ve created with a custom geometry in the shape of a triangle. Even though I’ve set the frameColor to (0,0,0,0), it seems that the frame itself is still used for click detection on the button.

Is there a way to direct the button to use the triangular geometry itself for click detection? I was able to do this with a DirectSlider’s thumb by setting the frameSize to (0,0,0,0), but when I try the same trick with the DirectButton it appears that the button becomes impossible to click.


Have you tried this :

b = DirectButton(geom = .....

Just make sure to rotate your custom button mesh -90 (before export) to see it properly. Guess what, the custom button is not checked for collision !

Thank you for the suggestion!

Visibility is not an issue; I can see the geometry clearly. But when I try and click on the object, my click doesn’t push the button. Only if I set the frameSize to something larger than (0,0,0,0) can I click the button… and then only in the (invisible) frame.

Does anyone know how to use the geometry for click detection (or why that seems to work with DirectSlider but not DirectButton)?


I was trying to tell you that the custom button geometry is not included for click detection. That’s why I tried to set the DirectButton object perfectly perpendicular to the camera, while the custom button geom is perfectly parallel to the camera.
It checks for the background card only, and ignoring the custom geom. I’m afraid it’s the way it works, not using collision ray, for instance, to check collision against it.
Are you sure about click detection in DirectSlider perform exactly NOT the same ? Have you used non-rectangle shape geom, e.g. a triangle just like your button, or a circle ?

Ah, I understand now. Thank you for the clarification!

I may have been wrong about the button behavior; I’ll have to go back and look.


Any Direct objects (buttons, slider’s thumb, etc.) only use rectangular bounds to interact with the mouse. Check DirectGuiBase.py, in getBounds(), the bounds generation is there, now I’m sure.
Then you must use collision detection to detect your custom geom precisely. Hehe, lucky me, I’ve used my own since the beginning.
Good luck !