From e329e432ff304be65ff69f0cf06f487462b20eaf Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Wed, 24 Mar 2021 17:37:41 +0800 Subject: [PATCH] =?UTF-8?q?CHART-18080=20=E5=8F=98=E9=87=8F=E5=90=8D?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/itextfield/UINumberField.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java index 8176905fe..62d24c56a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java @@ -39,7 +39,10 @@ public class UINumberField extends UITextField { private boolean isContentChanged = false; private boolean fillNegativeNumber = true; - private boolean isInputMethodChange = false; + /** + * 输入法输入完成一个字符输入过程的标记。开始输入的时候是true,输入完矫正光标后为false + */ + private boolean isInputMethodOnceInserting = false; private int insertOffset = 0; public UINumberField() { @@ -73,7 +76,7 @@ public class UINumberField extends UITextField { addInputMethodListener(new InputMethodListener() { @Override public void inputMethodTextChanged(InputMethodEvent event) { - isInputMethodChange = true; + isInputMethodOnceInserting = true; } @Override @@ -84,8 +87,8 @@ public class UINumberField extends UITextField { addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent e) { - if (isInputMethodChange) { - isInputMethodChange = false; + if (isInputMethodOnceInserting) { + isInputMethodOnceInserting = false; setCaretPosition(insertOffset); } else { insertOffset = e.getDot(); @@ -219,7 +222,7 @@ public class UINumberField extends UITextField { } public void remove(int offs, int len) throws BadLocationException { - if (isInputMethodChange) { + if (isInputMethodOnceInserting) { return; } super.remove(offs, len);