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