'After panning the object, the objects resets to original position when mouse button is clicked next time pan operation
I am working on transformations with the cube in open tk. The pan operations are set on the right mouse button. Select the right mouse button and drag. The cube moves according to changes in screen x and y coordinates correctly. The only issue I am facing is, when button is released and again the right mouse button the clicked, the cube is shifted to original position which should not happen. The next pan operation should start from the previous pan position. The mouse event and pan code is shared.
internal new void MouseDown(object sender, System.Windows.Forms.MouseEventArgs mouse)
{
MouseStartPosition = new Vector2(mouse.X, mouse.Y);
}
internal new void MouseMove(object sender, System.Windows.Forms.MouseEventArgs mouse)
{
if (mouse.Button == MouseButtons.Right)
{
MouseNewPosition = new Vector2(mouse.X, mouse.Y);
Pan();
}
internal void Pan()
{
CubeRender.translateX = MouseNewPosition.X - MouseStartPosition.X;
CubeRender.translateY = MouseStartPosition.Y - MouseNewPosition.Y;
this.Invalidate();
this.Refresh();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
