cancel
Showing results for 
Search instead for 
Did you mean: 

How to move a curve by mouse movement?

Zwei.9
Associate III

I want to implement a function: after the mouse 0690X00000AAJ6UQAX.bmpclick on the curve to be able to drag the curve until the mouse is released

1 ACCEPTED SOLUTION

Accepted Solutions

Forgot to mention. In your call to moveTo(x,y) you would ofcourse juse use the current y-coordinate of the graph so that you don't move the graph accidentally in the y axis, but only in the x axis.

And consider relative coordinates and consider edges, so, actually, you would use deltaX - Forget what i said earlier.

graph.moveTo(deltaX, graph.getY());

 Because deltaX can be negative.

/Martin

View solution in original post

7 REPLIES 7
Martin KJELDSEN
Chief III

Hi @Zwei.9​,

Just override handleDragEvent() in your view and use deltaX argument of the drag event to move your graph. This will work using your mouse in the simulator.

/Martin

Hello.@Martin KJELDSEN​ 

I overrided handleDragEvent() in my view.

void MainWindowView::handleDragEvent(const DragEvent& evt)
{
           graph.moeTo(20+evt.getDeltaX(),20+evt.getDeltaY());
}

When I run it and drag the curve, it wobbles a lot.What's the reason?

Maybe we implemented wobbly behavior in Graph::moeTo(). Or did you mean moveTo()? =) 

You're not supposed to use the coordinates like that. You actually just have to use newX and newY without the offset (20). The delta is just for your inspection if you need it for anything.

The delta is how far you've moved your finger since last tick.

/Martin

Thank you very much!

Forgot to mention. In your call to moveTo(x,y) you would ofcourse juse use the current y-coordinate of the graph so that you don't move the graph accidentally in the y axis, but only in the x axis.

And consider relative coordinates and consider edges, so, actually, you would use deltaX - Forget what i said earlier.

graph.moveTo(deltaX, graph.getY());

 Because deltaX can be negative.

/Martin

Pretty good!Thank you very much!You are my lucky star!

Great, no problem! 🙂