Why don't you simply set the button position according to the mouse position
? Something like :

// pseudo-code :)
GetMousePos(x, y);
SetBoutonPos(x, y);

Perhaps there's an evidence I didn't think about, but I think it'd be a good
solution for your problem... There may be a little "jump" of the button at
the beginning of the "drag-process" but nothing very crappy...

     - Cortex : HL Albator coder and mapper ( www.hlalbator.fr.st )
     - email : [EMAIL PROTECTED]  &  ICQ : 71548738

----- Original Message -----
From: "Nate Lovallo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 27, 2002 9:32 PM
Subject: [hlcoders] More Drag and Drop vgui Probs


| Ok, ive basically got it working, but theres 2 problems.
| 1. The button lags behind my mouse, and ofter the cursor leaves the button
when you drag it.  For now im just
| makig it stop dragging if this happens, but Id really like to make it
catch upto the mouse.
|
| 2. Everytime first time cursorMoved gets called after mouePressed, it sets
the buttons position to the middle of
| the screen
|
| here is my code:
|
| void CHandler_DragIt:: mousePressed(MouseCode code,Panel* panel)
| {
|
| panel->getApp()->getCursorPos(mousex,mousey);
| m_bDragging = true;
| m_pCommandButton->getPos(m_iaDragStart[0],m_iaDragStart[1]);
| ConsolePrint( "mousedown\n" );
|
| }
| void CHandler_DragIt::mouseReleased(MouseCode code,Panel* panel)
| {
|
| ConsolePrint( "mouseup\n" );
| m_bDragging = false;
| App::getInstance()->setMouseCapture(null);//???
| }
| void CHandler_DragIt::cursorMoved(int x,int y,Panel* panel)
| {
| if(m_bDragging)
| {
| char sz[32];
| panel->getApp()->getCursorPos(x,y);
| m_pCommandButton->setPos((x-m_iaDragStart[0]),(y-m_iaDragStart[1]));
| sprintf (sz, " %d , %d\n", (x-m_iaDragStart[0]), (y-m_iaDragStart[1]));
| ConsolePrint(sz);
| }
| }
|
| Cheers
| Inbeastic
|
|
| _______________________________________________
| To unsubscribe, edit your list preferences, or view the list archives,
please visit:
| http://list.valvesoftware.com/mailman/listinfo/hlcoders
|
|


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to