public void run() { while (!cancel) { try { resetKey = true; synchronized (this) { wait(1500); } } catch (InterruptedException ex) { } synchronized (this) { if (resetKey && lastButton != null && inputMethodListener != null) { int caret = inputMethodListener.getCaretPosition() + 1; if (caret <= inputMethodListener.getText().length()) { lastButton = null; lastButtonCharIndex = -1; InputMethodEvent event = new InputMethodEvent(InputMethodEvent.CARET_POSITION_CHANGED, caret, inputMethodListener.getText()); inputMethodListener.caretPositionChanged(event); } } } } }
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); } }
SwtButton button = (SwtButton) e.nextElement(); if (ev.keyCode == button.getKeyCode()) { int caret = inputMethodListener.getCaretPosition(); String tmp = inputMethodListener.getText(); synchronized (this) {
int caret = inputMethodListener.getCaretPosition();
int caret = inputMethodListener.getCaretPosition();