Hi all and happy new year
I need to detect whe the mouse leftclick is being held while moving the mouse upward so how can i do that

Thank you

Edited 4 Years Ago by shandoosheri: n/a

You need to capture the MouseDown and MouseUp event, set a boolean, and remember the original coordinates:

bool MouseIsDragging = false;
point Start = new point();
private void MyForm_MouseDown(object sender, MouseEventArgs e)
{
    MouseIsDragging = true;
    Start.X = e.X;
    Start.Y = e.Y;
}
private void MyForm_MouseUp(object sender, MouseEventArgs e)
{
    MouseIsDragging = false;
    if (e.Y > Start.Y) //can't remember if Y increases or decreases as you go up...
        MouseHasBeenDraggedUp(); //Condition is met, do something
}

//If this needs to be monitored in realtime, and not just when the mouse button is up:
private void MyForm_MouseHover(object sender, MouseEventArgs e)
{
   if (MouseIsDragging == true && e.Y > Start.Y)
   {
      MouseHasBeenDraggedUp();// Condition met
   }  
}

Edited 4 Years Ago by skatamatic: n/a

This question has already been answered. Start a new discussion instead.