DirectGUI MouseDown

I want to get a mouse down event (“mouse1”) on a DirectFrame (or button, I don’t really care). I’m trying to make it so I can drag things around on screen. It all works, but I can’t get what button was clicked, unless I start the drag on mouse up with a command.

I know how to have a button command do off when the mouse is released, and I know how to get a mouse down even for the window.

Do I have to mess with my MouseWatcher directly or is there some trick I’m missing?

Also, I noticed DirectButton’s clickable area is a simply axis aligned rectangular bounding box, which is pretty bad when they are rotated. I’m going to be drawing lines somehow (I was thinking DirectFrames), and it would be handy if they were clickable, but the clickable area would be way off. Is there an easy fix/workaround for this?

Incase it matters, I’m not in the main window, though my window is properly setup to get all the events and work with DirectGUI. Window setup (and all other relevant code) is here:
https://github.com/Craig-Macomber/Panda3D-Shader-Generator/blob/v3/editor.py

Bear with me as I’m having trouble understanding what you’re asking…

Okay.

What does this mean? Could you describe the problem more? Sorry for my lack of understanding-ness :wink:

Do you know of all the DGG.* events?
Such as:

myframebuttonthing.bind(DGG.ENTER)
myframebuttonthing.bind(DGG.EXIT)
myframebuttonthing.bind(DGG.B1PRESS)
myframebuttonthing.bind(DGG.B1RELEASE)

myframebuttonthing.bind(DGG.B2PRESS)
#... etc

Or perhaps you mean something else entirely? My apologies ahead of time.

Dunno for sure of any fix for this.

Hope this helps,
~powerpup118

You provided exactly what I needed despite the confusion. Thanks!

I needed self.frame.bind(DGG.B1PRESS,self.startDrag)

I was unaware of the bind method. I can now drag my frames around.

I’m still looking for a fix for the clickable areas. It seems like one could use the button’s matrix to transform the click position and check if its truly over the button, and I can do this, but it does not solve the whole issue because diagonal buttons on top would capture large areas of clicks preventing clicks that should hit buttons that are behind them.