04-08-2002, 07:04 AM
http://www.mfcogl.com/Drag%20&%20Drop%20-%20MFC%20&%20OpenGL%20Page.htm has an example of a drag and drop method but it appears very complicated with setCapture calls and translating the mouse point to window coordinates. i thought something like:
static void mouse (int button, int state, int x, int y )
{
if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
x=startx;
y=starty;
}
if(button == GLUT_LEFT_BUTTON && state == GLUT_UP)
{
ot->object[obj].x1=ot->object[obj].x1+(x-startx);
ot->object[obj].y1=ot->object[obj].y1+(y-starty);
ot->object[obj].x2=ot->object[obj].x2+(x-startx);
ot->object[obj].y2=ot->object[obj].y2+(y-starty);
ot->object[obj].x3=ot->object[obj].x3+(x-startx);
ot->object[obj].y3=ot->object[obj].y3+(y-starty);
ot->object[obj].x4=ot->object[obj].x4+(x-startx);
ot->object[obj].y4=ot->object[obj].y4+(y-starty);
}
this however does not work. the file menu on my user interface pops down and then the object disappears(dont ask me how). it seems straight enough but obviously not. any help would be great.
ps the drag is not important once it ends up translating from one point to the other
static void mouse (int button, int state, int x, int y )
{
if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
x=startx;
y=starty;
}
if(button == GLUT_LEFT_BUTTON && state == GLUT_UP)
{
ot->object[obj].x1=ot->object[obj].x1+(x-startx);
ot->object[obj].y1=ot->object[obj].y1+(y-starty);
ot->object[obj].x2=ot->object[obj].x2+(x-startx);
ot->object[obj].y2=ot->object[obj].y2+(y-starty);
ot->object[obj].x3=ot->object[obj].x3+(x-startx);
ot->object[obj].y3=ot->object[obj].y3+(y-starty);
ot->object[obj].x4=ot->object[obj].x4+(x-startx);
ot->object[obj].y4=ot->object[obj].y4+(y-starty);
}
this however does not work. the file menu on my user interface pops down and then the object disappears(dont ask me how). it seems straight enough but obviously not. any help would be great.
ps the drag is not important once it ends up translating from one point to the other