6614972: JSlider value should not change on right-click
authorrupashka
Tue, 29 Apr 2008 17:48:01 +0400
changeset 456 8ded0dbe4aaa
parent 455 11d2fe22f245
child 457 8682623ee3c3
6614972: JSlider value should not change on right-click Summary: WindowsSliderUI won't use the right mouse button for change slider position Reviewed-by: alexp
jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Tue Apr 29 15:47:17 2008 +0400
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Tue Apr 29 17:48:01 2008 +0400
@@ -982,7 +982,7 @@
                              "LEFT", "positiveUnitIncrement",
                           "KP_LEFT", "positiveUnitIncrement",
                          }),
-
+            "Slider.onlyLeftMouseButtonDrag", Boolean.FALSE,
 
             "Spinner.ancestorInputMap",
                new UIDefaults.LazyInputMap(new Object[] {
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Tue Apr 29 15:47:17 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Tue Apr 29 17:48:01 2008 +0400
@@ -1364,6 +1364,7 @@
                         "LEFT", "positiveUnitIncrement",
                      "KP_LEFT", "positiveUnitIncrement",
                  }),
+            "Slider.onlyLeftMouseButtonDrag", Boolean.TRUE,
 
             // *** Spinner
             "Spinner.font", monospacedPlain12,
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java	Tue Apr 29 15:47:17 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java	Tue Apr 29 17:48:01 2008 +0400
@@ -1573,6 +1573,11 @@
 
             // Clicked in the Thumb area?
             if (thumbRect.contains(currentMouseX, currentMouseY)) {
+                if (UIManager.getBoolean("Slider.onlyLeftMouseButtonDrag")
+                        && !SwingUtilities.isLeftMouseButton(e)) {
+                    return;
+                }
+
                 switch (slider.getOrientation()) {
                 case JSlider.VERTICAL:
                     offset = currentMouseY - thumbRect.y;
@@ -1584,6 +1589,11 @@
                 isDragging = true;
                 return;
             }
+
+            if (!SwingUtilities.isLeftMouseButton(e)) {
+                return;
+            }
+
             isDragging = false;
             slider.setValueIsAdjusting(true);