Example usage for java.awt.event InputMethodEvent CARET_POSITION_CHANGED

List of usage examples for java.awt.event InputMethodEvent CARET_POSITION_CHANGED

Introduction

In this page you can find the example usage for java.awt.event InputMethodEvent CARET_POSITION_CHANGED.

Prototype

int CARET_POSITION_CHANGED

To view the source code for java.awt.event InputMethodEvent CARET_POSITION_CHANGED.

Click Source Link

Document

The event type indicating a changed insertion point in input method text.

Usage

From source file:CodePointInputMethod.java

/**
 * Move the insertion point one position to the left in the composed text.
 * Do not let the caret move to the left of the "\\u" or "\\U".
 *///from w  w  w  .  j  a v  a2  s  .c  om
private void moveCaretLeft() {
    int len = buffer.length();
    if (--insertionPoint < 2) {
        insertionPoint++;
        beep();
    } else if (format == SURROGATE_PAIR && insertionPoint == 7) {
        insertionPoint = 8;
        beep();
    }

    context.dispatchInputMethodEvent(InputMethodEvent.CARET_POSITION_CHANGED, null, 0,
            TextHitInfo.leading(insertionPoint), null);
}

From source file:CodePointInputMethod.java

/**
 * Move the insertion point one position to the right in the composed text.
 *//*from  w  w w .  j av a2 s.c om*/
private void moveCaretRight() {
    int len = buffer.length();
    if (++insertionPoint > len) {
        insertionPoint = len;
        beep();
    }

    context.dispatchInputMethodEvent(InputMethodEvent.CARET_POSITION_CHANGED, null, 0,
            TextHitInfo.leading(insertionPoint), null);
}