Java Code Examples for java.awt.event.InputMethodEvent

The following are top voted examples for showing how to use java.awt.event.InputMethodEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: CodePointInputMethod.java   View source code 6 votes vote down vote up
/**
 * 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".
 */
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);
}
 
Example 2
Project: OpenJSharp   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
Example 3
Project: OpenJSharp   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
Example 4
Project: OpenJSharp   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
Example 5
Project: OpenJSharp   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
Example 6
Project: jdk8u-jdk   File: CodePointInputMethod.java   View source code 6 votes vote down vote up
/**
 * 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".
 */
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);
}
 
Example 7
Project: jdk8u-jdk   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
Example 8
Project: jdk8u-jdk   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
Example 9
Project: jdk8u-jdk   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
Example 10
Project: jdk8u-jdk   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
Example 11
Project: openjdk-jdk10   File: CodePointInputMethod.java   View source code 6 votes vote down vote up
/**
 * 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".
 */
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);
}
 
Example 12
Project: openjdk-jdk10   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
Example 13
Project: openjdk-jdk10   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
Example 14
Project: openjdk-jdk10   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   when    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
Example 15
Project: openjdk-jdk10   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
Example 16
Project: openjdk9   File: CodePointInputMethod.java   View source code 6 votes vote down vote up
/**
 * 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".
 */
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);
}
 
Example 17
Project: openjdk9   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
Example 18
Project: openjdk9   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
Example 19
Project: openjdk9   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   when    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
Example 20
Project: openjdk9   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
Example 21
Project: jdk8u_jdk   File: CodePointInputMethod.java   View source code 6 votes vote down vote up
/**
 * 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".
 */
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);
}
 
Example 22
Project: jdk8u_jdk   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
Example 23
Project: jdk8u_jdk   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
Example 24
Project: jdk8u_jdk   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
Example 25
Project: jdk8u_jdk   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
Example 26
Project: lookaside_java-1.8.0-openjdk   File: CodePointInputMethod.java   View source code 6 votes vote down vote up
/**
 * 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".
 */
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);
}
 
Example 27
Project: lookaside_java-1.8.0-openjdk   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
Example 28
Project: lookaside_java-1.8.0-openjdk   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
Example 29
Project: lookaside_java-1.8.0-openjdk   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
Example 30
Project: lookaside_java-1.8.0-openjdk   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
Example 31
Project: j2se_for_android   File: JFormattedTextField.java   View source code 6 votes vote down vote up
/**
 * Processes any input method events, such as
 * <code>InputMethodEvent.INPUT_METHOD_TEXT_CHANGED</code> or
 * <code>InputMethodEvent.CARET_POSITION_CHANGED</code>.
 * 
 * @param e
 *            the <code>InputMethodEvent</code>
 * @see InputMethodEvent
 */
protected void processInputMethodEvent(InputMethodEvent e) {
	AttributedCharacterIterator text = e.getText();
	int commitCount = e.getCommittedCharacterCount();

	// Keep track of the composed text
	if (text != null) {
		int begin = text.getBeginIndex();
		int end = text.getEndIndex();
		composedTextExists = ((end - begin) > commitCount);
	} else {
		composedTextExists = false;
	}

	super.processInputMethodEvent(e);
}
 
Example 32
Project: intellij-ce-playground   File: EditorComponentImpl.java   View source code 6 votes vote down vote up
@Override
protected void processInputMethodEvent(InputMethodEvent e) {
  super.processInputMethodEvent(e);
  if (!e.isConsumed()) {
    switch (e.getID()) {
      case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
        myEditor.replaceInputMethodText(e);
        // No breaks over here.

        //noinspection fallthrough
      case InputMethodEvent.CARET_POSITION_CHANGED:
        myEditor.inputMethodCaretPositionChanged(e);
        break;
    }
    e.consume();
  }
}
 
Example 33
Project: smoothcsv   File: CsvGridSheetTable.java   View source code 6 votes vote down vote up
@Override
protected void processInputMethodEvent(InputMethodEvent e) {
  super.processInputMethodEvent(e);
  if (Env.getOS() == Env.OS_WINDOWS) {
    return;
  }

  if (!e.isConsumed()) {
    // Try to install the editor
    CsvGridEditorComponent editorComponent = editQuickly();
    if (editorComponent != null) {
      editorComponent.ignoreNextKeyEvent();
      if (MacroRecorder.isRecording()) {
        MacroRecorder.getInstance().recordCommand("grid:StartQuickEdit");
      }
      editorComponent.processInputMethodEvent(e);
    }
    e.consume();
  }
}
 
Example 34
Project: infobip-open-jdk-8   File: CodePointInputMethod.java   View source code 6 votes vote down vote up
/**
 * 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".
 */
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);
}
 
Example 35
Project: infobip-open-jdk-8   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}
 
Example 36
Project: infobip-open-jdk-8   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchEvent(AWTEvent event) {
    // some host input method adapters may dispatch input method events
    // through the Java event queue. If the component that the event is
    // intended for isn't an active client, or if we're using below-the-spot
    // input, we need to dispatch this event
    // to the input window. Note that that component is not necessarily the
    // current client component, since we may have switched clients while
    // the event was in the queue.
    if (event instanceof InputMethodEvent) {
        if (((Component) event.getSource()).getInputMethodRequests() == null
                || (useBelowTheSpotInput() && !dispatchingCommittedText)) {
            getCompositionAreaHandler(true).processInputMethodEvent((InputMethodEvent) event);
        }
    } else {
        // make sure we don't dispatch our own key events back to the input method
        if (!dispatchingCommittedText) {
            super.dispatchEvent(event);
        }
    }
}
 
Example 37
Project: infobip-open-jdk-8   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Dispatches committed text from XIM to the awt event queue. This
 * method is invoked from the event handler in canvas.c in the
 * AWT Toolkit thread context and thus inside the AWT Lock.
 * @param   str     committed text
 * @param   long    when
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void dispatchCommittedText(String str, long when) {
    if (str == null)
        return;

    if (composedText == null) {
        AttributedString attrstr = new AttributedString(str);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             str.length(),
                             null,
                             null,
                             when);
    } else {
        // if there is composed text, wait until the preedit
        // callback is invoked.
        committedText = str;
    }
}
 
Example 38
Project: infobip-open-jdk-8   File: X11InputMethod.java   View source code 6 votes vote down vote up
/**
 * Flushes composed and committed text held in this context.
 * This method is invoked in the AWT Toolkit (X event loop) thread context
 * and thus inside the AWT Lock.
 */
// NOTE: This method may be called by privileged threads.
//       This functionality is implemented in a package-private method
//       to insure that it cannot be overridden by client subclasses.
//       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void flushText() {
    String flush = (committedText != null ? committedText : "");
    if (composedText != null) {
        flush += composedText.toString();
    }

    if (!flush.equals("")) {
        AttributedString attrstr = new AttributedString(flush);
        postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
                             attrstr.getIterator(),
                             flush.length(),
                             null,
                             null,
                             EventQueue.getMostRecentEventTime());
        composedText = null;
        committedText = null;
    }
}
 
Example 39
Project: jdk8u-dev-jdk   File: CodePointInputMethod.java   View source code 6 votes vote down vote up
/**
 * 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".
 */
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);
}
 
Example 40
Project: jdk8u-dev-jdk   File: InputMethodContext.java   View source code 6 votes vote down vote up
public void dispatchInputMethodEvent(int id,
            AttributedCharacterIterator text, int committedCharacterCount,
            TextHitInfo caret, TextHitInfo visiblePosition) {
    // We need to record the client component as the source so
    // that we have correct information if we later have to break up this
    // event into key events.
    Component source;

    source = getClientComponent();
    if (source != null) {
        InputMethodEvent event = new InputMethodEvent(source,
                id, text, committedCharacterCount, caret, visiblePosition);

        if (haveActiveClient() && !useBelowTheSpotInput()) {
            source.dispatchEvent(event);
        } else {
            getCompositionAreaHandler(true).processInputMethodEvent(event);
        }
    }
}