I was attempting to get a drag-and-drop system working with DirectButton - but I’ve run into a problem. I use
base.accept("mouse1-up",setDragOff)
to turn off drag, but to find out if the button is pressed, I had trouble.
My intention was to use
base.accept("mouse1",setDrag)
and some position checking to initiate dragging, since the command property doesn’t register until release. However, it seems that clicking on a direct button will not fire the ‘mouse1’ event.
Currently I’m working on detecting what button the mouse was over when the mouse was clicked. To do so, I’m creating a “bounding box” using getX() to getX() + getWidth(), etc. However, the coordinates these create don’t seem to be correct. What single point on a button do getX() and getY() return? (Also, is there a better way to go about this?)
Slight development: GetWidth and getHeight are independent of the scale I’ve set, so I can get the actual width and height by multiplying by my scale. However, I’m still uncertain what getX() and getY() really are pointing to.
The (0, 0) origin of a gui item is arbitrary. Use guiItem.getBounds() instead. This returns a VBase4 whose components are the (left, right, bottom, top) boundaries of the gui item, excluding any bevel width.
Cool - however, I’m using ‘scale’ to make the buttons a little less ginormous, and from my testing it looks like getBounds() will return the same coordinates no matter what ‘scale’ is set to. Should I be setting some sort of geom scale too?