Skip to content

Commit

Permalink
fix: colorpicker move on input (#656)
Browse files Browse the repository at this point in the history
* Add copy code function to Color Picker

Signed-off-by: leewyatt <[email protected]>

* Modify to not return null and Fix #503

Signed-off-by: leewyatt <[email protected]>

* Add licenses and tests

Signed-off-by: leewyatt <[email protected]>

* update licenses

Signed-off-by: leewyatt <[email protected]>

* Remove extra blank lines, remove null

Signed-off-by: leewyatt <[email protected]>

* 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 <[email protected]>

* updated copyright

---------

Signed-off-by: leewyatt <[email protected]>
Co-authored-by: Almas Baimagambetov <[email protected]>
Co-authored-by: José Pereda <[email protected]>
  • Loading branch information
3 people authored Mar 12, 2024
1 parent fbb75b1 commit a07ff34
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a07ff34

Please sign in to comment.