DirectGuiWidget: Click and drag

I’m trying to click and drag window elements (direct frames) around the screen, but I’m having some difficulty. I noticed there’s an undocumented guiDragTask, with a ‘state’ variable that I’m not sure what to put in.

Has anyone had any luck with guiDragTask or am I going about this completely the wrong way. If there’s an easier way, please let me know.

Hey buddie

DirectFrame is a NodePath too :slight_smile: … then:


fly=False
def handler():
    global fly
    if not fly:
        fly=True
        taskMgr.add(windowFly, "Drag")
    else:
        fly=False
        taskMgr.remove("Drag")


def windowFly(task):
    global frame
    mouse=base.mouseWatcherNode.getMouse()
    frame.setPos(mouse.getX(), 0, mouse.getY())

    return task.cont

frame=DirectFrame(
       frameColor=(1,1,1,0.99),
       frameSize=(-0.5, 0.5, -0.5, 0.5),
       pos=(0,0,0),
       frameTexture="../models/gui/charme.png",
       sortOrder=10,
       enableEdit=True
)

frame.accept("mouse1", handler)
 

Pay attencion in :
frame.accept(“mouse1”, handler)

:smiley: G-Luck Boy

Thanks, if you look at the other topic I posted in Scripting issues though they came up with more of the solution I needed.

Apparently there’s a .bind(command) method I missed which is very VERY useful.

discourse.panda3d.org/viewtopic.php?t=9220