fix button firing so that mouse movement does not interfere (fixes #3529)

This commit is contained in:
Ben Fry
2015-08-05 08:48:53 -04:00
parent b939a38aa9
commit f1b64923ee
+12 -5
View File
@@ -155,11 +155,11 @@ implements MouseListener, MouseMotionListener, ActionListener {
@Override
public void mouseClicked(MouseEvent e) {
if (isEnabled()) {
shift = e.isShiftDown();
actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
null, e.getModifiers()));
}
// if (isEnabled()) {
// shift = e.isShiftDown();
// actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
// null, e.getModifiers()));
// }
}
@@ -171,6 +171,13 @@ implements MouseListener, MouseMotionListener, ActionListener {
@Override
public void mousePressed(MouseEvent e) {
setPressed(true);
// Need to fire here (or on mouse up) because mouseClicked()
// won't be fired if the user nudges the mouse while clicking.
// https://github.com/processing/processing/issues/3529
shift = e.isShiftDown();
actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
null, e.getModifiers()));
}