From a07ff3431bd92fda6635f1500d915bd74831710e Mon Sep 17 00:00:00 2001 From: leewyatt Date: Tue, 12 Mar 2024 22:35:37 +0900 Subject: [PATCH] fix: colorpicker move on input (#656) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add copy code function to Color Picker Signed-off-by: leewyatt * Modify to not return null and Fix #503 Signed-off-by: leewyatt * Add licenses and tests Signed-off-by: leewyatt * update licenses Signed-off-by: leewyatt * Remove extra blank lines, remove null Signed-off-by: leewyatt * Update to JUnit 5 API * Prevent ColorPicker area from moving on mouse scroll and keyboard inputs: The area was previously shifting due to ScrollPane default behaviors. * Remove extraneous whitespace line * Refactored code placement and added comments as per review feedback. * Update kit/src/main/java/com/oracle/javafx/scenebuilder/kit/util/control/paintpicker/colorpicker/ColorPicker.java Co-authored-by: José Pereda * updated copyright --------- Signed-off-by: leewyatt Co-authored-by: Almas Baimagambetov Co-authored-by: José Pereda --- .../control/paintpicker/colorpicker/ColorPicker.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/util/control/paintpicker/colorpicker/ColorPicker.java b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/util/control/paintpicker/colorpicker/ColorPicker.java index 9852abf01..1aad8d911 100644 --- a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/util/control/paintpicker/colorpicker/ColorPicker.java +++ b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/util/control/paintpicker/colorpicker/ColorPicker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Gluon and/or its affiliates. + * Copyright (c) 2022, 2024, Gluon and/or its affiliates. * All rights reserved. Use is subject to license terms. * * This file is available and licensed under the following license: @@ -38,6 +38,7 @@ import com.oracle.javafx.scenebuilder.kit.util.control.paintpicker.gradientpicker.GradientPickerStop; import javafx.beans.value.ChangeListener; import javafx.event.ActionEvent; +import javafx.event.Event; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.geometry.Bounds; @@ -48,7 +49,9 @@ import javafx.scene.control.TextField; import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; +import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; +import javafx.scene.input.ScrollEvent; import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; @@ -155,6 +158,7 @@ private void initialize() { assert green_textfield != null; assert blue_textfield != null; assert alpha_slider != null; + assert picker_scrollpane != null; hue_slider.setStyle(makeHueSliderCSS()); // Make the grad for hue slider @@ -252,6 +256,11 @@ private void initialize() { picker_region.pressedProperty().addListener(liveUpdateListener); hue_slider.pressedProperty().addListener(liveUpdateListener); alpha_slider.pressedProperty().addListener(liveUpdateListener); + + // Disable ColorPicker movement on focus, by blocking scroll and key (Home, End, PgUp, PgDn, arrows) events + picker_scrollpane.addEventFilter(KeyEvent.ANY, Event::consume); + picker_scrollpane.addEventFilter(ScrollEvent.SCROLL, Event::consume); + // paint combobox add values paintCombobox.getItems().setAll(CSS_CODE, JAVA_CODE); paintCombobox.getSelectionModel().select(0);