Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robot fails to click on Mac OS X / Java 7 #26

Closed
croesch opened this issue Feb 5, 2014 · 1 comment
Closed

Robot fails to click on Mac OS X / Java 7 #26

croesch opened this issue Feb 5, 2014 · 1 comment

Comments

@croesch
Copy link
Collaborator

croesch commented Feb 5, 2014

Issue by caillette from Thursday Jun 06, 2013 at 14:00 GMT
Originally opened as alexruiz/fest-swing-1.x#19


When running tests on Mac OS X (10.8.4) and Java 7 (1.7.0_21-b12) the mouse pointer jitters over text fields and takes dozens of seconds before it finally clicks on them. The tests don't really fail but become slow enough to prevent from building.

Emmanuel Puybaret (author of 2 books on Java) found the following workaround. The System property resolution should go in a constant but we favored readability.

org.fest.swing.monitor.WindowStatus

@RunsInEDT
private void mouseMove(final Window w, Point point) {
  final int x = point.x;
  final int y = point.y;
  if (x == 0 || y == 0) return;
  robot.mouseMove(x, y);
  // ************************
  // EP : Dispatch missing MouseEvent under Mac OS X / Java 7
  if (System.getProperty("os.name").startsWith("Mac OS X")
      && System.getProperty("java.version").startsWith("1.7")
      && w.isShowing()
      && w.getBounds().contains(x, y)) {
    java.awt.EventQueue.invokeLater(new Runnable() {
         @Override
         public void run() {
           w.dispatchEvent(new java.awt.event.MouseEvent(w, java.awt.event.MouseEvent.MOUSE_MOVED,
                System.currentTimeMillis(), 0, x - w.getX(), y - w.getY(), x, y, 0, false, 0));
         }
       });
  }
  // EP : End of modification
  // ************************
  Dimension windowSize = sizeOf(w);
  if (windowSize.width > windowSize.height) robot.mouseMove(x + sign, y);
  else robot.mouseMove(x, y + sign);
  sign = -sign;
}
@croesch
Copy link
Collaborator Author

croesch commented Feb 9, 2014

Might have to do with #25

@croesch croesch closed this as completed Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant