Just in case you want to use this to pop up a popup menu, the way
NOT to do it is to check for button 3 from the mouse, as this is
not portable (ever checked how many buttons a Mac mouse has?).
Instead, you should check whether this is a popup mouse click, using
something like this inside BOTH of your mousePressed and
mouseReleased methods (don't ask we why it needs to be in both, I
just know that it has to be):
if (evt.isPopupTrigger())
// pop up your popup menu
HTH,
Robert.
On Sat, 14 Nov 1998, Chris Sommers wrote:
> Assume you have MouseEvent in a variable "event"
>
> int m = event.getModifiers();
> if (m & InputEvent.BUTTON1_MASK) <----- detects button 1
>
> Take a look at InputEvents - it has a lot of static
> constants used for determining which button was pressed, if
> CTRL, ALT or SHIFT were pressed, also etc.
>
> Karthik Vishwanath wrote:
> >
> > Hi all,
> > On receiving a mousePressed, how does one determine which mouse
> > button is the one clicked?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Robert P Biuk-Aghai, University of Macau, Faculty of Science and Technology
http://hyperg.sftw.umac.mo/robert/ tel: +853-3974365 fax: +853-838314
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Microsoft isn't the answer. Microsoft is the question and the answer is no.