iphone
asked on
How to catch right and left mouse pressed at the same time?
Hi Experts..
i wanna have 3 mouse pressed event
1st : left mouse pressed
2nd : Right mouse Pressed
3rd : right and left mouse pressed
how can i handle my 3rd event(right and left pressed) in the same time...because as we know..we cant do it in the almost exact time..so that it would run the 1st event/2nd event first before running the 3rd event
so how does to avoid 1st/2nd even to occured before my 3rd?
i wanna have 3 mouse pressed event
1st : left mouse pressed
2nd : Right mouse Pressed
3rd : right and left mouse pressed
how can i handle my 3rd event(right and left pressed) in the same time...because as we know..we cant do it in the almost exact time..so that it would run the 1st event/2nd event first before running the 3rd event
so how does to avoid 1st/2nd even to occured before my 3rd?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it has been a long time since i used java..
but please try this..
public void mouseClicked(MouseEvent e)
{
if (e.getButton() == (MouseEvent.BUTTON1 | MouseEvent.BUTTON2) )
// do something here
else if (e.getButton() == MouseEvent.BUTTON1 )
// do something here
else if (e.getButton() == MouseEvent.BUTTON2 )
// do something here
}
ASKER
Thx for your guys quick replies
but think malfunction84 thrown something for me to think on it
but think malfunction84 thrown something for me to think on it
You'll need to add some logic to your code to handle it.
eg. checking if the other is already pressed when the other other is
And adding a slight delay to wait for the other to be pressed before processing the single press