From 9ae5af11644e2f9a15ca6240d5e5ee023a5f41af Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Tue, 20 Jul 2021 14:05:13 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-53949=20UIBoundSpinner=E4=B9=9F=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E8=8E=B7=E5=8F=96=E7=84=A6=E7=82=B9=E5=90=8E=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E4=BF=AE=E6=94=B9=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/gui/ispinner/UISpinner.java | 12 ++++++++---- .../widget/ui/designer/component/UIBoundSpinner.java | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 9d10da3a72..22f6cb246e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -58,7 +58,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver * Spinner内的数字文本框长度 */ private int numberFieldColumns; - private boolean hasTextFieldFocus = false; + private boolean textFieldFocus = false; public UISpinner() { @@ -197,6 +197,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver this.nextButton.setEnabled(flag); } + public void setTextFieldFocus(boolean textFieldFocus) { + this.textFieldFocus = textFieldFocus; + } + @Override public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); @@ -319,7 +323,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver @Override public void mouseWheelMoved(MouseWheelEvent e) { - if (hasTextFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { + if (textFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { setValue(value - e.getWheelRotation()); } } @@ -333,12 +337,12 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver textField.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { - hasTextFieldFocus = true; + textFieldFocus = true; } @Override public void focusLost(FocusEvent e) { - hasTextFieldFocus = false; + textFieldFocus = false; textField.getDocument().removeDocumentListener(docListener); textField.setValue(value); textField.getDocument().addDocumentListener(docListener); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java index 426d27f1ae..ea90f3f397 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java @@ -23,8 +23,14 @@ public class UIBoundSpinner extends UISpinner{ @Override protected void initTextFiledListeners(){ this.getTextField().addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + setTextFieldFocus(true); + } + @Override public void focusLost(FocusEvent e) { + setTextFieldFocus(false); setTextFieldValue(getTextField().getValue()); setTextField(value); }