Name: sdR10048 Date: 10/11/2002
JDK1.4 doc for
public java.awt.event.MouseEvent(Component source, int id,
long when, int modifiers,
int x, int y, int clickCount,
boolean popupTrigger, int button)
says:
> Constructs a MouseEvent object with the specified source component, ty
> pe, modifiers, coordinates, and click count.
>
> Note that passing in an invalid id results in unspecified behavior.
>
> Parameters:
> source - the Component that originated the event
> id - the integer that identifies the event
> when - a long int that gives the time the event occurred
> modifiers - the modifier keys down during event (e.g. shift, ctrl,
> alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be
> used, but both models should not be mixed in one event. Use of the
> extended modifiers is preferred.
> x - the horizontal x coordinate for the mouse location
> y - the vertical y coordinate for the mouse location
> clickCount - the number of mouse clicks associated with event
> popupTrigger - a boolean, true if this event is a trigger for a popup
> menu
> button - which of the mouse buttons has changed state. NOBUTTON,
> BUTTON1, BUTTON2 or BUTTON3.
> Throws:
> IllegalArgumentException - if if an invalid button value is passed in.
It is not clear what if say 'modifiers' == MouseEvent.BUTTON1_MASK and
'button' == MouseEvent.BUTTON2. What getButton() will return.
Currently JDK returns what has been specified by 'modifiers'.
And point # 2: what is the right behavior here if 'modifiers' ==
MouseEvent.BUTTON1_MASK | MouseEvent.BUTTON3_MASK?
See small demo about it:
import java.awt.event.*;
import java.awt.*;
class Test {
public static void main(String args[]) {
MouseEvent event =
new MouseEvent(new Container(),
MouseEvent.MOUSE_CLICKED,
0,
MouseEvent.BUTTON1_MASK, // button # 1
0, 0, 0, true,
MouseEvent.BUTTON2); // button # 2
System.out.println("button: "+event.getButton()); // button # ?
}
}
Demo output:
] ~/tmp
] java Test
button: 1
Need for jck test development.
======================================================================
###@###.### 2004-09-15