Skip to content

Commit 7070f28

Browse files
committed
fixed some problems with hotkeys.
1 parent 14ab7dd commit 7070f28

File tree

7 files changed

+32
-10
lines changed

7 files changed

+32
-10
lines changed

src/com/ss/editor/ui/control/property/impl/AbstractFloatPropertyControl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import com.ss.editor.ui.control.property.AbstractPropertyControl;
66
import com.ss.editor.ui.css.CSSClasses;
77
import com.ss.editor.ui.css.CSSIds;
8+
import com.ss.editor.ui.util.UIUtils;
89

910
import org.jetbrains.annotations.NotNull;
1011
import org.jetbrains.annotations.Nullable;
1112

1213
import java.util.function.BiConsumer;
1314

14-
import javafx.event.Event;
1515
import javafx.scene.layout.HBox;
1616
import rlib.function.SixObjectConsumer;
1717
import rlib.ui.control.input.FloatTextField;
@@ -42,7 +42,7 @@ protected void createComponents(@NotNull final HBox container) {
4242

4343
valueField = new FloatTextField();
4444
valueField.setId(CSSIds.ABSTRACT_PARAM_CONTROL_COMBO_BOX);
45-
valueField.setOnKeyPressed(Event::consume);
45+
valueField.setOnKeyPressed(UIUtils::consumeIfIsNotHotKey);
4646
valueField.addChangeListener((observable, oldValue, newValue) -> updateValue());
4747
valueField.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));
4848

src/com/ss/editor/ui/control/property/impl/AbstractIntArrayPropertyControl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.ss.editor.ui.control.property.AbstractPropertyControl;
55
import com.ss.editor.ui.css.CSSClasses;
66
import com.ss.editor.ui.css.CSSIds;
7+
import com.ss.editor.ui.util.UIUtils;
78

89
import org.jetbrains.annotations.NotNull;
910
import org.jetbrains.annotations.Nullable;
@@ -84,7 +85,8 @@ protected void reload() {
8485
* Update the value.
8586
*/
8687
private void updateValue(final KeyEvent event) {
87-
if (event != null) event.consume();
88+
UIUtils.consumeIfIsNotHotKey(event);
89+
8890
if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;
8991

9092
final String textValue = valueField.getText();

src/com/ss/editor/ui/control/property/impl/AbstractIntegerPropertyControl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import com.ss.editor.ui.control.property.AbstractPropertyControl;
55
import com.ss.editor.ui.css.CSSClasses;
66
import com.ss.editor.ui.css.CSSIds;
7+
import com.ss.editor.ui.util.UIUtils;
78

89
import org.jetbrains.annotations.NotNull;
910
import org.jetbrains.annotations.Nullable;
1011

1112
import java.util.function.BiConsumer;
1213

13-
import javafx.event.Event;
1414
import javafx.scene.layout.HBox;
1515
import rlib.function.SixObjectConsumer;
1616
import rlib.ui.control.input.IntegerTextField;
@@ -41,7 +41,7 @@ protected void createComponents(@NotNull final HBox container) {
4141

4242
valueField = new IntegerTextField();
4343
valueField.setId(CSSIds.ABSTRACT_PARAM_CONTROL_COMBO_BOX);
44-
valueField.setOnKeyPressed(Event::consume);
44+
valueField.setOnKeyPressed(UIUtils::consumeIfIsNotHotKey);
4545
valueField.addChangeListener((observable, oldValue, newValue) -> updateValue());
4646
valueField.prefWidthProperty().bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));
4747

src/com/ss/editor/ui/control/property/impl/AbstractQuaternionPropertyControl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.ss.editor.ui.control.property.AbstractPropertyControl;
1010
import com.ss.editor.ui.css.CSSClasses;
1111
import com.ss.editor.ui.css.CSSIds;
12+
import com.ss.editor.ui.util.UIUtils;
1213

1314
import org.jetbrains.annotations.NotNull;
1415
import org.jetbrains.annotations.Nullable;
@@ -148,7 +149,8 @@ protected void reload() {
148149
* Updating rotation.
149150
*/
150151
private void updateRotation(@Nullable final KeyEvent event) {
151-
if (event != null) event.consume();
152+
UIUtils.consumeIfIsNotHotKey(event);
153+
152154
if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;
153155

154156
final Quaternion oldValue = getPropertyValue();

src/com/ss/editor/ui/control/property/impl/AbstractVector2fPropertyControl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.ss.editor.ui.control.property.AbstractPropertyControl;
88
import com.ss.editor.ui.css.CSSClasses;
99
import com.ss.editor.ui.css.CSSIds;
10+
import com.ss.editor.ui.util.UIUtils;
1011

1112
import org.jetbrains.annotations.NotNull;
1213
import org.jetbrains.annotations.Nullable;
@@ -130,7 +131,8 @@ protected void reload() {
130131
* Update the vector.
131132
*/
132133
protected void updateVector(@Nullable final KeyEvent event) {
133-
if (event != null) event.consume();
134+
UIUtils.consumeIfIsNotHotKey(event);
135+
134136
if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;
135137

136138
final FloatTextField xField = getXField();

src/com/ss/editor/ui/control/property/impl/AbstractVector3fPropertyControl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.ss.editor.ui.control.property.AbstractPropertyControl;
88
import com.ss.editor.ui.css.CSSClasses;
99
import com.ss.editor.ui.css.CSSIds;
10+
import com.ss.editor.ui.util.UIUtils;
1011

1112
import org.jetbrains.annotations.NotNull;
1213
import org.jetbrains.annotations.Nullable;
@@ -149,7 +150,8 @@ protected void reload() {
149150
* Update the vector.
150151
*/
151152
protected void updateVector(@Nullable final KeyEvent event) {
152-
if (event != null) event.consume();
153+
UIUtils.consumeIfIsNotHotKey(event);
154+
153155
if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;
154156

155157
final FloatTextField xField = getXField();

src/com/ss/editor/ui/util/UIUtils.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import javafx.scene.control.Tooltip;
2626
import javafx.scene.control.TreeItem;
2727
import javafx.scene.control.TreeView;
28+
import javafx.scene.input.KeyEvent;
2829
import javafx.scene.layout.Pane;
2930
import javafx.scene.paint.Color;
3031
import javafx.util.Duration;
@@ -331,12 +332,25 @@ public static <T> void getAllItems(final Array<TreeItem<T>> container, final Tre
331332
}
332333

333334
/**
334-
* Конвертирование Color в ColorRGBA.
335+
* Convert a color from {@link Color} to {@link ColorRGBA}.
335336
*/
336-
public static ColorRGBA convertColor(final Color newValue) {
337+
@NotNull
338+
public static ColorRGBA convertColor(@NotNull final Color newValue) {
337339
return new ColorRGBA((float) newValue.getRed(), (float) newValue.getGreen(), (float) newValue.getBlue(), (float) newValue.getOpacity());
338340
}
339341

342+
/**
343+
* Consume an event if the event is not hotkey.
344+
*
345+
* @param event the event.
346+
*/
347+
public static void consumeIfIsNotHotKey(@Nullable final KeyEvent event) {
348+
if (event == null || event.isControlDown() || event.isShiftDown()) {
349+
return;
350+
}
351+
event.consume();
352+
}
353+
340354
private UIUtils() {
341355
throw new RuntimeException();
342356
}

0 commit comments

Comments
 (0)