|
|
|
@ -142,7 +142,6 @@ public class AwtMouseInput implements MouseInput, MouseListener, MouseWheelListe |
|
|
|
|
|
|
|
|
|
public void setCursorVisible(boolean visible) { |
|
|
|
|
if (this.visible != visible) { |
|
|
|
|
|
|
|
|
|
lastKnownLocation.x = lastKnownLocation.y = 0; |
|
|
|
|
|
|
|
|
|
this.visible = visible; |
|
|
|
@ -150,9 +149,10 @@ public class AwtMouseInput implements MouseInput, MouseListener, MouseWheelListe |
|
|
|
|
SwingUtilities.invokeLater(new Runnable() { |
|
|
|
|
public void run() { |
|
|
|
|
component.setCursor(newVisible ? null : getTransparentCursor()); |
|
|
|
|
if (!newVisible) |
|
|
|
|
if (!newVisible) { |
|
|
|
|
recenterMouse(component); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -214,69 +214,71 @@ public class AwtMouseInput implements MouseInput, MouseListener, MouseWheelListe |
|
|
|
|
return 3; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mouseClicked(MouseEvent arg0) { |
|
|
|
|
public void mouseClicked(MouseEvent awtEvt) { |
|
|
|
|
// MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(arg0), false);
|
|
|
|
|
// listener.onMouseButtonEvent(evt);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mousePressed(MouseEvent arg0) { |
|
|
|
|
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(arg0), true, arg0.getX(), arg0.getY()); |
|
|
|
|
evt.setTime(arg0.getWhen()); |
|
|
|
|
public void mousePressed(MouseEvent awtEvt) { |
|
|
|
|
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(awtEvt), true, awtEvt.getX(), awtEvt.getY()); |
|
|
|
|
evt.setTime(awtEvt.getWhen()); |
|
|
|
|
synchronized (eventQueue) { |
|
|
|
|
eventQueue.add(evt); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mouseReleased(MouseEvent arg0) { |
|
|
|
|
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(arg0), false, arg0.getX(), arg0.getY()); |
|
|
|
|
evt.setTime(arg0.getWhen()); |
|
|
|
|
public void mouseReleased(MouseEvent awtEvt) { |
|
|
|
|
MouseButtonEvent evt = new MouseButtonEvent(getJMEButtonIndex(awtEvt), false, awtEvt.getX(), awtEvt.getY()); |
|
|
|
|
evt.setTime(awtEvt.getWhen()); |
|
|
|
|
synchronized (eventQueue) { |
|
|
|
|
eventQueue.add(evt); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mouseEntered(MouseEvent arg0) { |
|
|
|
|
if (!visible) |
|
|
|
|
recenterMouse(arg0.getComponent()); |
|
|
|
|
public void mouseEntered(MouseEvent awtEvt) { |
|
|
|
|
if (!visible) { |
|
|
|
|
recenterMouse(awtEvt.getComponent()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mouseExited(MouseEvent arg0) { |
|
|
|
|
if (!visible) |
|
|
|
|
recenterMouse(arg0.getComponent()); |
|
|
|
|
public void mouseExited(MouseEvent awtEvt) { |
|
|
|
|
if (!visible) { |
|
|
|
|
recenterMouse(awtEvt.getComponent()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mouseWheelMoved(MouseWheelEvent arg0) { |
|
|
|
|
int dwheel = arg0.getUnitsToScroll(); |
|
|
|
|
public void mouseWheelMoved(MouseWheelEvent awtEvt) { |
|
|
|
|
int dwheel = awtEvt.getUnitsToScroll(); |
|
|
|
|
wheelPos += dwheel * WHEEL_AMP; |
|
|
|
|
cursorMoved = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mouseDragged(MouseEvent arg0) { |
|
|
|
|
mouseMoved(arg0); |
|
|
|
|
public void mouseDragged(MouseEvent awtEvt) { |
|
|
|
|
mouseMoved(awtEvt); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mouseMoved(MouseEvent arg0) { |
|
|
|
|
public void mouseMoved(MouseEvent awtEvt) { |
|
|
|
|
if (isRecentering) { |
|
|
|
|
// MHenze (cylab) Fix Issue 35:
|
|
|
|
|
// As long as the MouseInput is in recentering mode, nothing is done until the mouse is entered in the component
|
|
|
|
|
// by the events generated by the robot. If this happens, the last known location is resetted.
|
|
|
|
|
if ((centerLocation.x == arg0.getX() && centerLocation.y == arg0.getY()) || eventsSinceRecenter++ == 5) { |
|
|
|
|
lastKnownLocation.x = arg0.getX(); |
|
|
|
|
lastKnownLocation.y = arg0.getY(); |
|
|
|
|
if ((centerLocation.x == awtEvt.getX() && centerLocation.y == awtEvt.getY()) || eventsSinceRecenter++ == 5) { |
|
|
|
|
lastKnownLocation.x = awtEvt.getX(); |
|
|
|
|
lastKnownLocation.y = awtEvt.getY(); |
|
|
|
|
isRecentering = false; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// MHenze (cylab) Fix Issue 35:
|
|
|
|
|
// Compute the delta and absolute coordinates and recenter the mouse if necessary
|
|
|
|
|
int dx = arg0.getX() - lastKnownLocation.x; |
|
|
|
|
int dy = arg0.getY() - lastKnownLocation.y; |
|
|
|
|
int dx = awtEvt.getX() - lastKnownLocation.x; |
|
|
|
|
int dy = awtEvt.getY() - lastKnownLocation.y; |
|
|
|
|
location.x += dx; |
|
|
|
|
location.y += dy; |
|
|
|
|
if (!visible) { |
|
|
|
|
recenterMouse(arg0.getComponent()); |
|
|
|
|
recenterMouse(awtEvt.getComponent()); |
|
|
|
|
} |
|
|
|
|
lastKnownLocation.x = arg0.getX(); |
|
|
|
|
lastKnownLocation.y = arg0.getY(); |
|
|
|
|
lastKnownLocation.x = awtEvt.getX(); |
|
|
|
|
lastKnownLocation.y = awtEvt.getY(); |
|
|
|
|
|
|
|
|
|
cursorMoved = true; |
|
|
|
|
} |
|
|
|
@ -294,9 +296,9 @@ public class AwtMouseInput implements MouseInput, MouseListener, MouseWheelListe |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int getJMEButtonIndex( MouseEvent arg0 ) { |
|
|
|
|
private int getJMEButtonIndex(MouseEvent awtEvt) { |
|
|
|
|
int index; |
|
|
|
|
switch (arg0.getButton()) { |
|
|
|
|
switch (awtEvt.getButton()) { |
|
|
|
|
default: |
|
|
|
|
case MouseEvent.BUTTON1: //left
|
|
|
|
|
index = MouseInput.BUTTON_LEFT; |
|
|
|
|