From b0436d5a819a8b2063ff32ed6b0d82fb69939d01 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Wed, 7 Jul 2021 16:36:20 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-53949=20UISpinner=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=84=A6=E7=82=B9=E5=90=8E=E6=89=8D=E5=8F=AF=E4=BB=A5=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E8=B0=83=E6=95=B4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/gui/ispinner/UISpinner.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 454b1e5b99..9d10da3a72 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,6 +58,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver * Spinner内的数字文本框长度 */ private int numberFieldColumns; + private boolean hasTextFieldFocus = false; public UISpinner() { @@ -318,7 +319,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver @Override public void mouseWheelMoved(MouseWheelEvent e) { - if (isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { + if (hasTextFieldFocus && isEnabled() && e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { setValue(value - e.getWheelRotation()); } } @@ -330,8 +331,14 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver textField.getDocument().removeDocumentListener(docListener); textField.getDocument().addDocumentListener(docListener); textField.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + hasTextFieldFocus = true; + } + @Override public void focusLost(FocusEvent e) { + hasTextFieldFocus = false; textField.getDocument().removeDocumentListener(docListener); textField.setValue(value); textField.getDocument().addDocumentListener(docListener);