Click here to Skip to main content
15,505,828 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my code i want to detect if the user pressed the right mouse click.

What I have tried:

i wrote
if(MouseEvent.Button3==1){//code}
and it doesn't work, but if i type
if(MouseEvent.Button1==1){//code}
(left mouse click) it's work.
what's wrong?
Posted
Updated 27-Sep-22 5:12am
v2
Comments
Richard MacCutchan 27-Sep-22 9:32am    
See below.
NoName900 27-Sep-22 9:42am    
i tried MouseEvent.Button2, doesn't work either

1 solution

The MousEvent button values correspond to their names, i.e BUTTON3 value is 3, not 1. But you should really call the getButton method to find out which button was pressed.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900