本文整理匯總了Java中android.inputmethodservice.Keyboard.KEYCODE_CANCEL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard.KEYCODE_CANCEL屬性的具體用法?Java Keyboard.KEYCODE_CANCEL怎麽用?Java Keyboard.KEYCODE_CANCEL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.inputmethodservice.Keyboard
的用法示例。
在下文中一共展示了Keyboard.KEYCODE_CANCEL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onLongPress
@Override
protected boolean onLongPress(Key key) {
if (key.codes[0] == Keyboard.KEYCODE_CANCEL) {
getOnKeyboardActionListener().onKey(LatinKeyboard.KEYCODE_OPTIONS, null);
return true;
}
if(key.codes[0] == -113) {
Variables.setCtrlOn();
draw(new Canvas());
return true;
}
if(key.codes[0] == -114) {
Variables.setAltOn();
draw(new Canvas());
return true;
}
return super.onLongPress(key);
}
示例2: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
Log.d("keydemo", "--------onkey-->" + primaryCode);
Editable editable = ed.getText();
int start = ed.getSelectionStart();
if (primaryCode == Keyboard.KEYCODE_CANCEL) {// 完成
hideKeyboard();
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {// 回退
if (editable != null && editable.length() > 0) {
if (onDelKeyEventListener != null) {
onDelKeyEventListener.onDeleteClick();
}
}
} else if (primaryCode == 57419) { // go left
if (start > 0) {
ed.setSelection(start - 1);
}
} else if (primaryCode == 57421) { // go right
if (start < ed.length()) {
ed.setSelection(start + 1);
}
} else {
editable.insert(start, Character.toString((char) primaryCode));
}
}
示例3: createKeyFromXml
@Override
protected Key createKeyFromXml(Resources res, Row parent, int x, int y,
XmlResourceParser parser) {
Key key = new LatinKey(res, parent, x, y, parser);
if (key.codes[0] == 10) {
mEnterKey = key;
} else if (key.codes[0] == ' ') {
mSpaceKey = key;
mSavedSpaceKey = new LatinKey(res, parent, x, y, parser);
} else if (key.codes[0] == Keyboard.KEYCODE_MODE_CHANGE) {
mModeChangeKey = key;
mSavedModeChangeKey = new LatinKey(res, parent, x, y, parser);
} else if (key.codes[0] == LatinKeyboardView.KEYCODE_LANGUAGE_SWITCH) {
mLanguageSwitchKey = key;
mSavedLanguageSwitchKey = new LatinKey(res, parent, x, y, parser);
} else if (key.codes[0] == Keyboard.KEYCODE_CANCEL) {
mCancelKey = key;
mSavedCancelKey = new LatinKey(res, parent, x, y, parser);
} else if (key.codes[0] == 44) { // comma
mCommaKey = key;
mSavedCommaKey = new LatinKey(res, parent, x, y, parser);
}
return key;
}
示例4: onLongPress
@Override
protected boolean onLongPress(Key key) {
if (key.codes[0] == Keyboard.KEYCODE_CANCEL) {
getOnKeyboardActionListener().onKey(KEYCODE_OPTIONS, null);
return true;
} else if (key.codes[0] == KEYCODE_LANGUAGE_SWITCH) {
getOnKeyboardActionListener().onKey(KEYCODE_INPUT_METHOD_SWITCH, null);
return true;
} else if (key.codes[0] == Keyboard.KEYCODE_DELETE) {
// turn off server predictions during long pressing backspace key
mLastPredictionEnabled = ((SoftKeyboard)getOnKeyboardActionListener()).turnOffPredictionsIfNeeded();
mLongPressedDelete = true;
return false;
} else {
return super.onLongPress(key);
}
}
示例5: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
EditText editText = getEditTextByTag();
if (editText == null) return;
Editable editable = editText.getText();
int start = editText.getSelectionStart();
int end = editText.getSelectionEnd();
if (primaryCode == Keyboard.KEYCODE_CANCEL) {// 完成
hideKeyboard(editText);
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {// 回退
start = start == end ? start - 1 : start;
if (!TextUtils.isEmpty(editable)) {
if (start >= 0 && end <= editable.length()) {
editable.delete(start, end);
}
}
} else {
editable.insert(start, Character.toString((char) primaryCode));
}
}
示例6: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
InputConnection inputConnection = getCurrentInputConnection();
playClick(primaryCode);
switch (primaryCode) {
case Keyboard.KEYCODE_DELETE:
inputConnection.deleteSurroundingText(1, 0);
break;
case Keyboard.KEYCODE_DONE:
inputConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
break;
case Keyboard.KEYCODE_CANCEL:
deleteWord(inputConnection);
break;
default:
String randomWord = randomWords.getRandomWord();
randomWord += " ";
inputConnection.commitText(randomWord, randomWord.length() + 1);
}
}
示例7: onKey
public void onKey(int primaryCode, int[] keyCodes) {
if (primaryCode == Keyboard.KEYCODE_DELETE) {
handleBackspace();
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
handleShift();
} else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
handleClose();
return;
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
handleModeChange();
} else if (primaryCode == EntryKeyboard.KEYCODE_ENTER) {
handleEnter();
} else {
handleCharacter(primaryCode, keyCodes);
// Switch back to old keyboard if we're not in capslock mode
if (mKeyboardState == KEYBOARD_STATE_SHIFTED) {
// skip to the unlocked state
mKeyboardState = KEYBOARD_STATE_CAPSLOCK;
handleShift();
}
}
}
示例8: onKey
public void onKey(int primaryCode, int[] keyCodes) {
this.wordProcessor.getChinesePhraseDictLinkedHashMap("(");
if (imeSwitch.handleKey(primaryCode)) {
this.strokereset();
this.inputView.setKeyboard(imeSwitch.getCurrentKeyboard());
return;
}
if (primaryCode == Keyboard.KEYCODE_CANCEL) {
this.handleClose();
return;
}
if (primaryCode == Keyboard.KEYCODE_DELETE) {
this.handleBackspace();
return;
}
if (primaryCode == IMEKeyboard.KEYCODE_ENTER) {
this.handleEnter();
}
if (primaryCode == Keyboard.KEYCODE_DONE) {
return;
}
this.handleKey(primaryCode, keyCodes);
}
示例9: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
Editable editable = mEditText.getText();
int start = mEditText.getSelectionStart();
if (primaryCode == Keyboard.KEYCODE_CANCEL) { // cancel
hideKeyboard();
} else if (primaryCode == Keyboard.KEYCODE_DELETE) { // 回退
if (editable != null && editable.length() > 0) {
if (start > 0) {
editable.delete(start - 1, start);
}
}
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) { // 大小寫切換
// changeKeyboart();
// mKeyboardView.setKeyboard(mLetterKeyboard);
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { // 數字與字母鍵盤互換
// if (isNumber) {
// isNumber = false;
// mKeyboardView.setKeyboard(mLetterKeyboard);
// } else {
// isNumber = true;
mKeyboardView.setKeyboard(mNumberKeyboard);
// }
} else if (primaryCode == 57419) { // 左移
if (start > 0) {
mEditText.setSelection(start - 1);
}
} else if (primaryCode == 57419) { // 右移
if (start > mEditText.length()) {
mEditText.setSelection(start + 1);
}
} else { // 輸入鍵盤值
editable.insert(start, Character.toString((char) primaryCode));
}
}
示例10: onKey
public void onKey(int primaryCode, int[] keyCodes) {
if (isWordSeparator(primaryCode)) {
// Handle separator. DCH: removed the space ' ' 0x0020
commitTyped(getCurrentInputConnection());
sendKey(primaryCode);
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {
handleBackspace();
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
handleShift();
} else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
handleClose();
} else if (primaryCode == ArabicKeyboardView.KEYCODE_LANGUAGE_SWITCH) {
handleLanguageSwitch();
} else if (primaryCode == ArabicKeyboardView.KEYCODE_OPTIONS) {
showOptionsMenu();
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE
&& mInputView != null) {
Keyboard current = mInputView.getKeyboard();
if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) {
setArabicKeyboard(mArabicKeyboard);
} else {
setArabicKeyboard(mSymbolsKeyboard);
mSymbolsKeyboard.setShifted(false);
}
} else {
handleCharacter(primaryCode);
}
}
示例11: onLongPress
@Override
protected boolean onLongPress(Key key) {
if (key.codes[0] == Keyboard.KEYCODE_CANCEL) {
getOnKeyboardActionListener().onKey(KEYCODE_OPTIONS, null);
return true;
} else {
return super.onLongPress(key);
}
}
示例12: onLongPress
@Override
protected boolean onLongPress(Key key) {
if (key.codes[0] == Keyboard.KEYCODE_CANCEL) {
getOnKeyboardActionListener().onKey(KEYCODE_OPTIONS, null);
return true;
} else if (key.codes[0] == 'ာ') {
getOnKeyboardActionListener().onKey(4139, null);
return true;
} else {
return super.onLongPress(key);
}
}
示例13: onLongPress
@Override
protected boolean onLongPress(Key key) {
if (key.codes[0] == Keyboard.KEYCODE_CANCEL) {
getOnKeyboardActionListener().onKey(KEYCODE_OPTIONS, null);
return true;
} else {
return super.onLongPress(key);
}
}
示例14: onKey
public void onKey(int primaryCode, int[] keyCodes) {
long when = SystemClock.uptimeMillis();
boolean mIsQuickPress = when < mLastKeyTime + QUICK_PRESS;
if (primaryCode != Keyboard.KEYCODE_DELETE || !mIsQuickPress) {
mDeleteCount = 0;
}
mLastKeyTime = when;
InputConnection ic = getCurrentInputConnection();
if (isWordSeparator(primaryCode)) {
// Handle separator
if (mComposing.length() > 0) {
commitTyped(ic);
}
sendKey(primaryCode);
if (mJustEnteredAutoSpace) {
swapPunctuationAndSpace();
}
updateShiftKeyState(getCurrentInputEditorInfo());
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {
handleBackspace();
mDeleteCount++;
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
handleShift();
} else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
handleClose();
return;
} else if (primaryCode == LatinKeyboardView.KEYCODE_OPTIONS) {
showChooseLexiconDialog();
// Show a menu or somethin'
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE
&& mInputView != null) {
Keyboard current = mInputView.getKeyboard();
if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) {
current = mQwertyKeyboard;
} else {
current = mSymbolsKeyboard;
}
mInputView.setKeyboard(current);
if (current == mSymbolsKeyboard) {
current.setShifted(false);
}
} else {
mJustEnteredAutoSpace = false;
handleCharacter(primaryCode, keyCodes);
}
}
示例15: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
if (primaryCode == Keyboard.KEYCODE_DELETE) {
keyDownUp(KeyEvent.KEYCODE_DEL);
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
mInputView.setShifted(!mInputView.isShifted());
} else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
requestHideSelf(0);
mInputView.closing();
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE
&& mInputView != null) {
Keyboard current = mInputView.getKeyboard();
if (current == mSymbolKeyboard) {
current = mQwertyKeyboard;
} else {
current = mSymbolKeyboard;
}
mInputView.setKeyboard(current);
} else {
if (isInputViewShown()) {
if (mInputView.isShifted()) {
primaryCode = Character.toUpperCase(primaryCode);
}
}
getCurrentInputConnection().commitText(
String.valueOf((char) primaryCode), 1);
}
}