changeset 6887:d06e9b3e8351

RT-36827: Clicking on a ComboBox no longer transfers focus to the ComboBox
author jgiles
date Tue, 29 Apr 2014 14:00:21 +1200
parents c4d8457b7064
children 668c601a2856
files modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java modules/controls/src/test/java/javafx/scene/control/ComboBoxTest.java
diffstat 2 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Tue Apr 29 13:27:17 2014 +1200
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ComboBoxBaseBehavior.java	Tue Apr 29 14:00:21 2014 +1200
@@ -238,6 +238,7 @@
     
     public void show() {
         if (! getControl().isShowing()) {
+            getControl().requestFocus();
             getControl().show();
         }
     }
--- a/modules/controls/src/test/java/javafx/scene/control/ComboBoxTest.java	Tue Apr 29 13:27:17 2014 +1200
+++ b/modules/controls/src/test/java/javafx/scene/control/ComboBoxTest.java	Tue Apr 29 14:00:21 2014 +1200
@@ -26,6 +26,7 @@
 package javafx.scene.control;
 
 import com.sun.javafx.scene.control.infrastructure.KeyModifier;
+import com.sun.javafx.scene.control.infrastructure.MouseEventFirer;
 import com.sun.javafx.tk.Toolkit;
 import javafx.css.PseudoClass;
 
@@ -1587,4 +1588,25 @@
 
         sl.dispose();
     }
+
+    @Test public void test_rt36827() {
+        final Button btn = new Button("focus owner");
+        final ComboBox<String> cb = new ComboBox<>(FXCollections.observableArrayList("a", "b", "c"));
+        VBox vbox = new VBox(btn, cb);
+
+        StageLoader sl = new StageLoader(vbox);
+        sl.getStage().requestFocus();
+        Toolkit.getToolkit().firePulse();
+        Scene scene = sl.getStage().getScene();
+
+        assertEquals(btn, scene.getFocusOwner());
+
+        MouseEventFirer mouse = new MouseEventFirer(cb);
+        mouse.fireMousePressAndRelease();
+
+        assertTrue(cb.isShowing());
+        assertEquals(cb, scene.getFocusOwner());
+
+        sl.dispose();
+    }
 }