diff --git a/modules/controls/src/main/java/javafx/scene/control/skin/ComboBoxBaseSkin.java b/modules/controls/src/main/java/javafx/scene/control/skin/ComboBoxBaseSkin.java --- a/modules/controls/src/main/java/javafx/scene/control/skin/ComboBoxBaseSkin.java +++ b/modules/controls/src/main/java/javafx/scene/control/skin/ComboBoxBaseSkin.java @@ -25,6 +25,7 @@ package javafx.scene.control.skin; +import javafx.event.Event; import javafx.scene.control.SkinBase; import com.sun.javafx.scene.control.behavior.ComboBoxBaseBehavior; import javafx.geometry.HPos; @@ -105,10 +106,10 @@ // arrowButton behaves like a button. // This is strongly tied to the implementation in ComboBoxBaseBehavior. // - arrowButton.addEventHandler(MouseEvent.MOUSE_ENTERED, (e) -> getBehavior().mouseEntered(e)); - arrowButton.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> { getBehavior().mousePressed(e); e.consume(); }); - arrowButton.addEventHandler(MouseEvent.MOUSE_RELEASED, (e) -> { getBehavior().mouseReleased(e); e.consume();}); - arrowButton.addEventHandler(MouseEvent.MOUSE_EXITED, (e) -> getBehavior().mouseExited(e)); + arrowButton.addEventHandler(MouseEvent.MOUSE_ENTERED, this::onMouseEntered); + arrowButton.addEventHandler(MouseEvent.MOUSE_PRESSED, this::onMousePressed); + arrowButton.addEventHandler(MouseEvent.MOUSE_RELEASED, this::onMouseReleased); + arrowButton.addEventHandler(MouseEvent.MOUSE_EXITED, this::onMouseExited); } getChildren().add(arrowButton); @@ -140,6 +141,36 @@ * * **************************************************************************/ + protected void onMouseEntered(MouseEvent e) { + ComboBoxBaseBehavior behavior = getBehavior(); + if (behavior != null) { + behavior.mouseEntered(e); + } + } + + protected void onMousePressed(MouseEvent e) { + ComboBoxBaseBehavior behavior = getBehavior(); + if (behavior != null) { + behavior.mousePressed(e); + e.consume(); + } + } + + protected void onMouseReleased(MouseEvent e) { + ComboBoxBaseBehavior behavior = getBehavior(); + if (behavior != null) { + behavior.mouseReleased(e); + e.consume(); + } + } + + protected void onMouseExited(MouseEvent e) { + ComboBoxBaseBehavior behavior = getBehavior(); + if (behavior != null) { + behavior.mouseExited(e); + } + } + /** * This method should return a Node that will be positioned within the * ComboBox 'button' area. diff --git a/modules/controls/src/main/java/javafx/scene/control/skin/ComboBoxPopupControl.java b/modules/controls/src/main/java/javafx/scene/control/skin/ComboBoxPopupControl.java --- a/modules/controls/src/main/java/javafx/scene/control/skin/ComboBoxPopupControl.java +++ b/modules/controls/src/main/java/javafx/scene/control/skin/ComboBoxPopupControl.java @@ -27,6 +27,7 @@ import com.sun.javafx.scene.control.FakeFocusTextField; import com.sun.javafx.scene.control.Properties; +import com.sun.javafx.scene.control.behavior.ComboBoxBaseBehavior; import com.sun.javafx.scene.input.ExtendedInputMethodRequests; import com.sun.javafx.scene.traversal.Algorithm; import com.sun.javafx.scene.traversal.Direction; @@ -35,6 +36,7 @@ import javafx.beans.InvalidationListener; import javafx.beans.value.ObservableValue; import javafx.css.Styleable; +import javafx.event.Event; import javafx.event.EventHandler; import javafx.geometry.Bounds; import javafx.geometry.HPos; @@ -256,6 +258,13 @@ } } + protected void onAutoHide(Event e) { + ComboBoxBaseBehavior behavior = getBehavior(); + if (behavior != null) { + getBehavior().onAutoHide(getPopup()); + } + } + /*************************************************************************** @@ -461,13 +470,16 @@ popup.setAutoHide(true); popup.setAutoFix(true); popup.setHideOnEscape(true); - popup.setOnAutoHide(e -> getBehavior().onAutoHide(popup)); + popup.setOnAutoHide(this::onAutoHide); popup.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> { // RT-18529: We listen to mouse input that is received by the popup // but that is not consumed, and assume that this is due to the mouse // clicking outside of the node, but in areas such as the // dropshadow. - getBehavior().onAutoHide(popup); + ComboBoxBaseBehavior behavior = getBehavior(); + if (behavior != null) { + behavior.onAutoHide(getPopup()); + } }); popup.addEventHandler(WindowEvent.WINDOW_HIDDEN, t -> { // Make sure the accessibility focus returns to the combo box