Harry
Harry

Reputation: 13329

Raphael - mouse events

How would you determine what mouse buttons was clicked on a mouse event?

I would like to make the distinction between left and right click.

Upvotes: 3

Views: 1399

Answers (1)

musefan
musefan

Reputation: 48415

I am not sure about the click event (though it may be worth a try) but if you use the mousedown event which should be good enough, then you can check the "which" property of the event.

The which property is an integer that determine the mouse button, and the values are mapped like...

1 = Left Button
2 = Middle Button
3 = Right Button

Example code...

element.mousedown(ElementMouseDown);

function ElementMouseDown(e) {
   switch(e.which){
      case 1://left button
         break;
      case 2://middle button
         break;
      case 3://right button
         break;
   }
}

Upvotes: 3

Related Questions