changeset 4949:684fa356f9b5

RT-26637 : Disabled buttons should not fire.
author mickf
date Tue, 10 Sep 2013 15:53:44 +0100
parents cc0cbc9a12e1
children 3c1652de9d60
files modules/controls/src/main/java/javafx/scene/control/Button.java modules/controls/src/main/java/javafx/scene/control/CheckBox.java modules/controls/src/main/java/javafx/scene/control/Hyperlink.java modules/controls/src/main/java/javafx/scene/control/MenuButton.java modules/controls/src/main/java/javafx/scene/control/SplitMenuButton.java modules/controls/src/main/java/javafx/scene/control/ToggleButton.java
diffstat 6 files changed, 32 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/control/Button.java	Tue Sep 10 09:46:05 2013 +1200
+++ b/modules/controls/src/main/java/javafx/scene/control/Button.java	Tue Sep 10 15:53:44 2013 +0100
@@ -181,7 +181,9 @@
 
     /** {@inheritDoc} */
     @Override public void fire() {
-        fireEvent(new ActionEvent());
+        if (!isDisabled()) {
+            fireEvent(new ActionEvent());
+        }
     }
 
     /** {@inheritDoc} */
--- a/modules/controls/src/main/java/javafx/scene/control/CheckBox.java	Tue Sep 10 09:46:05 2013 +1200
+++ b/modules/controls/src/main/java/javafx/scene/control/CheckBox.java	Tue Sep 10 15:53:44 2013 +0100
@@ -218,20 +218,22 @@
      * false.
      */
     @Override public void fire() {
-        if (isAllowIndeterminate()) {
-            if (!isSelected() && !isIndeterminate()) {
-                setIndeterminate(true);
-            } else if (isSelected() && !isIndeterminate()) {
-                setSelected(false);
-            } else if (isIndeterminate()) {
-                setSelected(true);
+        if (!isDisabled()) {
+            if (isAllowIndeterminate()) {
+                if (!isSelected() && !isIndeterminate()) {
+                    setIndeterminate(true);
+                } else if (isSelected() && !isIndeterminate()) {
+                    setSelected(false);
+                } else if (isIndeterminate()) {
+                    setSelected(true);
+                    setIndeterminate(false);
+                }
+            } else {
+                setSelected(!isSelected());
                 setIndeterminate(false);
             }
-        } else {
-            setSelected(!isSelected());
-            setIndeterminate(false);
+            fireEvent(new ActionEvent());
         }
-        fireEvent(new ActionEvent());
     }
 
     /** {@inheritDoc} */
--- a/modules/controls/src/main/java/javafx/scene/control/Hyperlink.java	Tue Sep 10 09:46:05 2013 +1200
+++ b/modules/controls/src/main/java/javafx/scene/control/Hyperlink.java	Tue Sep 10 15:53:44 2013 +0100
@@ -139,11 +139,13 @@
      * function will also {@link #setVisited} to true.
      */
     @Override public void fire() {
-        // Avoid causing an exception in the case that visited was bound
-        if (visited == null || !visited.isBound()) {
-            setVisited(true);
+        if (!isDisabled()) {
+            // Avoid causing an exception in the case that visited was bound
+            if (visited == null || !visited.isBound()) {
+                setVisited(true);
+            }
+            fireEvent(new ActionEvent());
         }
-        fireEvent(new ActionEvent());
     }
 
     /** {@inheritDoc} */
--- a/modules/controls/src/main/java/javafx/scene/control/MenuButton.java	Tue Sep 10 09:46:05 2013 +1200
+++ b/modules/controls/src/main/java/javafx/scene/control/MenuButton.java	Tue Sep 10 15:53:44 2013 +0100
@@ -237,7 +237,9 @@
      */
     @Override
     public void fire() {
-        fireEvent(new ActionEvent());
+        if (!isDisabled()) {
+            fireEvent(new ActionEvent());
+        }
     }
 
     /** {@inheritDoc} */
--- a/modules/controls/src/main/java/javafx/scene/control/SplitMenuButton.java	Tue Sep 10 09:46:05 2013 +1200
+++ b/modules/controls/src/main/java/javafx/scene/control/SplitMenuButton.java	Tue Sep 10 15:53:44 2013 +0100
@@ -105,7 +105,9 @@
      * Call the action when button is pressed.
      */
     @Override public void fire() {
-        fireEvent(new ActionEvent());
+        if (!isDisabled()) {
+            fireEvent(new ActionEvent());
+        }
     }
 
     /***************************************************************************
--- a/modules/controls/src/main/java/javafx/scene/control/ToggleButton.java	Tue Sep 10 09:46:05 2013 +1200
+++ b/modules/controls/src/main/java/javafx/scene/control/ToggleButton.java	Tue Sep 10 15:53:44 2013 +0100
@@ -226,8 +226,10 @@
     /** {@inheritDoc} */
     @Override public void fire() {
         // TODO (aruiz): if (!isReadOnly(isSelected()) {
-        setSelected(!isSelected());
-        fireEvent(new ActionEvent());
+        if (!isDisabled()) {
+            setSelected(!isSelected());
+            fireEvent(new ActionEvent());
+        }
     }
 
     /** {@inheritDoc} */