Browse Source

Pull request #4874: REPORT-53949 UISpinner获取焦点后才可以滚动调整值

Merge in DESIGN/design from ~TOMMY/design:feature/10.0 to feature/10.0

* commit 'b0436d5a819a8b2063ff32ed6b0d82fb69939d01':
  REPORT-53949 UISpinner获取焦点后才可以滚动调整值
feature/10.0
Tommy 3 years ago
parent
commit
04e7aaa5d6
  1. 9
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

9
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);

Loading…
Cancel
Save