protected char[] filterInputMode(char[] chars) { if (chars == null) { return new char[0]; } int inputMode = getInputMode(); char[] result = new char[chars.length]; int i, j; for (i = 0, j = 0; i < chars.length; i++) { if (inputMode == InputMethod.INPUT_ABC_UPPER) { result[j] = Character.toUpperCase(chars[i]); j++; } else if (inputMode == InputMethod.INPUT_ABC_LOWER) { result[j] = Character.toLowerCase(chars[i]); j++; } else if (inputMode == InputMethod.INPUT_123) { if (Character.isDigit(chars[i]) || chars[i] == '-' || chars[i] == '.') { result[j] = chars[i]; j++; } } } if (i != j) { char[] newresult = new char[j]; System.arraycopy(result, 0, newresult, 0, j); result = newresult; } return result; }
protected void insertText(String str) { if (str.length() > 0) { int caret = inputMethodListener.getCaretPosition(); String tmp = ""; synchronized (this) { if (lastButton != null) { caret++; lastButton = null; lastButtonCharIndex = -1; } if (caret > 0) { tmp += inputMethodListener.getText().substring(0, caret); } tmp += str; if (caret < inputMethodListener.getText().length()) { tmp += inputMethodListener.getText().substring(caret); } caret += str.length(); } if (!validate(tmp, inputMethodListener.getConstraints())) { return; } InputMethodEvent event = new InputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, caret, tmp); inputMethodListener.inputMethodTextChanged(event); event = new InputMethodEvent(InputMethodEvent.CARET_POSITION_CHANGED, caret, tmp); inputMethodListener.caretPositionChanged(event); } }
inputMethod.pointerDragged(p.x, p.y);