当前位置: 首页>>代码示例>>Java>>正文


Java InputMethodEvent类代码示例

本文整理汇总了Java中java.awt.event.InputMethodEvent的典型用法代码示例。如果您正苦于以下问题:Java InputMethodEvent类的具体用法?Java InputMethodEvent怎么用?Java InputMethodEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InputMethodEvent类属于java.awt.event包,在下文中一共展示了InputMethodEvent类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: moveCaretLeft

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:CodePointInputMethod.java

示例2: dispatchInputMethodEvent

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:InputMethodContext.java

示例3: dispatchEvent

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:InputMethodContext.java

示例4: dispatchCommittedText

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:X11InputMethod.java

示例5: flushText

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:X11InputMethod.java

示例6: dispatchCommittedText

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:X11InputMethod.java

示例7: processInputMethodEvent

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:25,代码来源:JFormattedTextField.java

示例8: processInputMethodEvent

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
@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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:EditorComponentImpl.java

示例9: processInputMethodEvent

import java.awt.event.InputMethodEvent; //导入依赖的package包/类
@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();
  }
}
 
开发者ID:kohii,项目名称:smoothcsv,代码行数:21,代码来源:CsvGridSheetTable.java


注:本文中的java.awt.event.InputMethodEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。