summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schuster <theBohemian@gmx.net>2006-05-19 13:23:48 +0000
committerRobert Schuster <theBohemian@gmx.net>2006-05-19 13:23:48 +0000
commit085ab59d1ee22673b1f5e3328558ae7ad6418e45 (patch)
treed51b6aed5a4299ec00eea51f651471f2c5b8d284
parent9c79b9d8d7c0ba31142772c5d656d7d07a2ed9da (diff)
downloadclasspath-085ab59d1ee22673b1f5e3328558ae7ad6418e45.tar.gz
2006-05-19 Robert Schuster <robertschuster@fsfe.org>
* java/awt/LightweightDispatcher.java: Added field dragButton and documentation for it. (handleMouseEvent): Rewritten MOUSE_PRESSED case in switch-statement, added subexpression to if-clause in MOUSE_RELEASED case.
-rw-r--r--ChangeLog7
-rw-r--r--java/awt/LightweightDispatcher.java25
2 files changed, 30 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 26f80c00f..50c505c1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2006-05-19 Robert Schuster <robertschuster@fsfe.org>
+ * java/awt/LightweightDispatcher.java: Added field dragButton and
+ documentation for it.
+ (handleMouseEvent): Rewritten MOUSE_PRESSED case in switch-statement,
+ added subexpression to if-clause in MOUSE_RELEASED case.
+
+2006-05-19 Robert Schuster <robertschuster@fsfe.org>
+
* javax/swing/metal/MetalButtonUI.java:
(update): Removed some subexpression from if-clause and call
updateWithGradient.
diff --git a/java/awt/LightweightDispatcher.java b/java/awt/LightweightDispatcher.java
index d3a2a9245..3be18910b 100644
--- a/java/awt/LightweightDispatcher.java
+++ b/java/awt/LightweightDispatcher.java
@@ -67,6 +67,13 @@ class LightweightDispatcher
* as well as the MOUSE_RELEASED event following the dragging.
*/
private Component dragTarget;
+
+ /**
+ * Stores the button number which started the drag operation. This is needed
+ * because we want to handle only one drag operation and only the button that
+ * started the dragging should be able to stop it (by a button release).
+ */
+ private int dragButton;
/**
* The last mouse event target. If the target changes, additional
@@ -196,10 +203,24 @@ class LightweightDispatcher
switch (ev.getID())
{
case MouseEvent.MOUSE_PRESSED:
- lastTarget = dragTarget = target;
+ // Handle the start of a drag operation or discard the event if
+ // one is already in progress. This prevents focus changes with the
+ // other mouse buttons when one is used for dragging.
+ if (dragTarget == null)
+ {
+ lastTarget = dragTarget = target;
+
+ // Save the button that started the drag operation.
+ dragButton = ev.getButton();
+ }
+ else
+ return false;
+
break;
case MouseEvent.MOUSE_RELEASED:
- if (dragTarget != null)
+ // Stop the drag operation only when the button that started
+ // it was released.
+ if (dragTarget != null && dragButton == ev.getButton())
{
target = dragTarget;
dragTarget = null;