summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;