Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See if left mouse button is held down in the OnMouseMove event

How do I detect if the left mouse button is being held down in the OnMouseMove event for a control?

like image 217
SchwartzE Avatar asked Feb 02 '10 17:02

SchwartzE


People also ask

How do I know if my mouse button is down?

We can listen to the mousedown and mouseup events to check if a mouse button is kept down after we press the mouse button. We set the window. onmousedown and window. onmouseup properties to functions that change the mouseDown count to listen for the mousedown and mouseup events on the whole tab.

What does holding down your left mouse button do?

Drag and drop is when you move something from one place to another. First select the item with the left mouse button and keep the button pressed down. Then move the mouse and the item on screen will move with the cursor. When you have the cursor and item in the position you want, release the left mouse button.

What is mouse down event?

MouseDown occurs when the user presses the mouse button; MouseUp occurs when the user releases the mouse button.

How do I know if my mouse is pressed in Javascript?

You can detect which button has been clicked by checking the MouseEvent. button property. This property will be available on mouse clicking events like: mousedown , mouseup , click , dblclick , contextmenu . The MouseEvent.


1 Answers

Your eventhandler for the OnMouseMove event should recieve a MouseEventArgs that should tell you if the left button is pressed

private void mouseMoveEventHandler(object sender, MouseEventArgs e)
{
   if(e.Button == MouseButtons.Left)
   {
     //do left stuff
   }
   else 
   {
     // do other stuff
   }
}
like image 117
Nifle Avatar answered Sep 22 '22 02:09

Nifle