changeset 203:8251a20df5da

RT-18672: ComboBox Scrollbar bug
author jgiles
date Thu, 29 Dec 2011 16:10:43 +1000
parents 466cddfdb54c
children 05a39a4e6788
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Thu Dec 29 15:50:42 2011 +1000
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java	Thu Dec 29 16:10:43 2011 +1000
@@ -27,13 +27,16 @@
 
 import javafx.scene.control.ComboBox;
 import com.sun.javafx.scene.control.behavior.ComboBoxListViewBehavior;
+import java.util.List;
 import javafx.beans.InvalidationListener;
 import javafx.beans.Observable;
 import javafx.beans.value.ChangeListener;
 import javafx.beans.value.ObservableValue;
 import javafx.collections.ObservableList;
 import javafx.event.EventHandler;
+import javafx.event.EventTarget;
 import javafx.scene.Node;
+import javafx.scene.Parent;
 import javafx.scene.control.*;
 import javafx.scene.input.KeyCode;
 import javafx.scene.input.KeyEvent;
@@ -266,6 +269,20 @@
         
         listView.addEventFilter(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
             @Override public void handle(MouseEvent t) {
+                // RT-18672: Without checking if the user is clicking in the 
+                // scrollbar area of the ListView, the comboBox will hide. Therefore,
+                // we add the check below to prevent this from happening.
+                EventTarget target = t.getTarget();
+                if (target instanceof Parent) {
+                    List<String> s = ((Parent) target).getStyleClass();
+                    if (s.contains("thumb") 
+                            || s.contains("track") 
+                            || s.contains("decrement-arrow") 
+                            || s.contains("increment-arrow")) {
+                        return;
+                    }
+                }
+                
                 comboBox.hide();
             }
         });