本文整理匯總了Java中java.awt.event.InputMethodEvent.consume方法的典型用法代碼示例。如果您正苦於以下問題:Java InputMethodEvent.consume方法的具體用法?Java InputMethodEvent.consume怎麽用?Java InputMethodEvent.consume使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.event.InputMethodEvent
的用法示例。
在下文中一共展示了InputMethodEvent.consume方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
}
示例2: 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();
}
}
示例3: caretPositionChanged
import java.awt.event.InputMethodEvent; //導入方法依賴的package包/類
public void caretPositionChanged(InputMethodEvent event) {
if (compositionArea != null) {
compositionArea.setCaret(event.getCaret());
}
// event has been handled, so consume it
event.consume();
}
示例4: inputMethodTextChanged
import java.awt.event.InputMethodEvent; //導入方法依賴的package包/類
@Override
public void inputMethodTextChanged(InputMethodEvent event) {
if (!ime_Cached) {
ime_SelectionStartPos = m_Field.getSelectionStart();
ime_SelectionEndPos = m_Field.getSelectionEnd();
if (ime_SelectionStartPos != ime_SelectionEndPos) {
ime_InitialLoc = Math.min(ime_SelectionStartPos, ime_SelectionEndPos);
} else {
ime_InitialLoc = m_Field.getCaretPosition();
}
ime_Cached = true;
ime_CachedChars = new StringBuffer();
}
int committedCharacterCount = event.getCommittedCharacterCount();
CharacterIterator iter = event.getText();
if (iter != null && ((iter.getEndIndex() - iter.getBeginIndex()) > committedCharacterCount)) {
if (ime_CachedChars != null) {
char ch = iter.first();
for (int i = 0; i < committedCharacterCount; i++) {
ime_CachedChars.append(ch);
ch = iter.next();
}
}
} else {
// Push the caret back as part of faking the text input.
int pos = ime_InitialLoc;
setCurrentPosition(pos);
// Fake the key input since handleTypedChar() does the right things.
if (ime_CachedChars != null) {
for (int i = 0; i < ime_CachedChars.length(); i++) {
handleTypedChar(ime_CachedChars.charAt(i));
setCurrentPosition(++pos);
}
}
if (iter != null) {
for (char ch = iter.first(); ch != CharacterIterator.DONE; ch = iter.next()) {
handleTypedChar(ch);
setCurrentPosition(++pos);
}
}
// for(int i = ime_SelectionStartPos; i < ime_SelectionEndPos; i++) {
// m_Translator.handleKeyDown(127);
// }
ime_Cached = false;
ime_CachedChars = null;
event.consume();
//commit the changes to the edit control
setModified(true);
// m_Translator.setModified(true);
// if (getCurrentField() != null)
// {
// getCurrentField().setModified(true);
// }
// if (getAssociatedParent() != null)
// {
// if (getAssociatedParent() instanceof ProjectTreeCellEditor)
// {
// ((ProjectTreeCellEditor)getAssociatedParent()).stopCellEditing();
// }
// }
}
}
示例5: inputMethodTextChanged
import java.awt.event.InputMethodEvent; //導入方法依賴的package包/類
public void inputMethodTextChanged(InputMethodEvent event) {
AttributedCharacterIterator text = event.getText();
int committedCharacterCount = event.getCommittedCharacterCount();
// extract composed text and prepare it for display
composedText = null;
caret = null;
if (text != null
&& committedCharacterCount < text.getEndIndex() - text.getBeginIndex()) {
// Create the composition area if necessary
if (compositionArea == null) {
createCompositionArea();
}
// copy the composed text
AttributedString composedTextString;
composedTextString = new AttributedString(text,
text.getBeginIndex() + committedCharacterCount, // skip over committed text
text.getEndIndex(), IM_ATTRIBUTES);
composedTextString.addAttribute(TextAttribute.FONT, compositionArea.getFont());
composedText = composedTextString.getIterator();
caret = event.getCaret();
}
if (compositionArea != null) {
compositionArea.setText(composedText, caret);
}
// send any committed text to the text component
if (committedCharacterCount > 0) {
inputMethodContext.dispatchCommittedText(((Component) event.getSource()),
text, committedCharacterCount);
// this may have changed the text location, so reposition the window
if (isCompositionAreaVisible()) {
compositionArea.updateWindowLocation();
}
}
// event has been handled, so consume it
event.consume();
}