Java Code Examples for android.view.KeyEvent#KEYCODE_FORWARD_DEL
The following examples show how to use
android.view.KeyEvent#KEYCODE_FORWARD_DEL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseKeyListener.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) { boolean handled; switch (keyCode) { case KeyEvent.KEYCODE_DEL: handled = backspace(view, content, keyCode, event); break; case KeyEvent.KEYCODE_FORWARD_DEL: handled = forwardDelete(view, content, keyCode, event); break; default: handled = false; break; } if (handled) { adjustMetaAfterKeypress(content); return true; } return super.onKeyDown(view, content, keyCode, event); }
Example 2
Source File: ElementController.java From UIAutomatorWD with MIT License | 6 votes |
private static boolean sendDeleteKeys(Element el) throws UiObjectNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { String tempTextHolder = ""; while (!el.getText().isEmpty() && !tempTextHolder.equalsIgnoreCase(el.getText())) { el.click(); for (int key : new int[]{KeyEvent.KEYCODE_DEL, KeyEvent.KEYCODE_FORWARD_DEL}) { tempTextHolder = el.getText(); final int length = tempTextHolder.length(); for (int count = 0; count < length; count++) { try { InteractionController interactionController = UiAutomatorBridge.getInstance().getInteractionController(); interactionController.sendKey(key, 0); } catch (Exception e) { System.out.println("UiAutomatorBridge.getInteractionController error happen!"); } } } } return el.getText().isEmpty(); }
Example 3
Source File: EditorActivity.java From spline with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_R: mViewModel.addRectLayer(); return true; case KeyEvent.KEYCODE_T: mViewModel.addTriangleLayer(); return true; case KeyEvent.KEYCODE_O: mViewModel.addOvalLayer(); return true; } if (mBinding.documentView.hasFocus()) { switch (keyCode) { case KeyEvent.KEYCODE_DEL: case KeyEvent.KEYCODE_FORWARD_DEL: return onContextMenuAction(DELETE); } if (event.isCtrlPressed()) { switch (keyCode) { case KeyEvent.KEYCODE_X: return onContextMenuAction(CUT); case KeyEvent.KEYCODE_C: return onContextMenuAction(COPY); case KeyEvent.KEYCODE_V: return onContextMenuAction(PASTE); case KeyEvent.KEYCODE_D: return onContextMenuAction(DUPLICATE); case KeyEvent.KEYCODE_G: return onContextMenuAction(GROUP); } } } return super.onKeyDown(keyCode, event); }
Example 4
Source File: FocusLogic.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
/** * Returns true only if this utility class handles the key code. */ public static boolean shouldConsume(int keyCode) { return (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END || keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN || keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL); }
Example 5
Source File: FastEdit.java From fastedit with Apache License 2.0 | 4 votes |
void onKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); switch (action) { case KeyEvent.ACTION_DOWN: { //输入模式 int unicodeChar = event.getUnicodeChar(); if (unicodeChar != 0) { input((char) unicodeChar); event.cancel(); } if (!event.isCanceled() && !event.isCtrlPressed() && !event.isAltPressed() && !event.isShiftPressed()) { switch (keyCode) { case KeyEvent.KEYCODE_TAB: //tab input(tabText); event.cancel(); break; case KeyEvent.KEYCODE_SPACE: //空格 input(' '); event.cancel(); break; case KeyEvent.KEYCODE_ENTER: //enter onKeyCodeEnter(event); event.cancel(); break; case KeyEvent.KEYCODE_DEL: //del onKeyCodeDel(event); event.cancel(); break; case KeyEvent.KEYCODE_FORWARD_DEL: //del onKeyCodeForwardDel(event); event.cancel(); break; case KeyEvent.KEYCODE_DPAD_LEFT: //left onKeyCodeDpadLeft(event); event.cancel(); break; case KeyEvent.KEYCODE_DPAD_RIGHT: //right onKeyCodeDpadRight(event); event.cancel(); break; case KeyEvent.KEYCODE_DPAD_UP: //up onKeyCodeDpadUp(event); event.cancel(); break; case KeyEvent.KEYCODE_DPAD_DOWN: //down onKeyCodeDpadDown(event); event.cancel(); break; case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_PAGE_DOWN: //page down onKeyCodePageDown(event); event.cancel(); break; case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_PAGE_UP: //page up onKeyCodePageUp(event); event.cancel(); break; case KeyEvent.KEYCODE_MOVE_HOME: onKeyCodeMoveHome(event); event.cancel(); break; case KeyEvent.KEYCODE_MOVE_END: onKeyCodeMoveEnd(event); event.cancel(); break; } } if (!event.isCanceled()) { //快捷键模式 if (onShortKey(event.isCtrlPressed(), event.isAltPressed(), event.isShiftPressed(), keyCode)) { event.cancel(); } } break; } } }
Example 6
Source File: AdapterInputConnection.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * @see BaseInputConnection#sendKeyEvent(android.view.KeyEvent) */ @Override public boolean sendKeyEvent(KeyEvent event) { if (DEBUG) { Log.w(TAG, "sendKeyEvent [" + event.getAction() + "] [" + event.getKeyCode() + "]"); } // If this is a key-up, and backspace/del or if the key has a character representation, // need to update the underlying Editable (i.e. the local representation of the text // being edited). if (event.getAction() == KeyEvent.ACTION_UP) { if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) { deleteSurroundingText(1, 0); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) { deleteSurroundingText(0, 1); return true; } else { int unicodeChar = event.getUnicodeChar(); if (unicodeChar != 0) { Editable editable = getEditable(); int selectionStart = Selection.getSelectionStart(editable); int selectionEnd = Selection.getSelectionEnd(editable); if (selectionStart > selectionEnd) { int temp = selectionStart; selectionStart = selectionEnd; selectionEnd = temp; } editable.replace(selectionStart, selectionEnd, Character.toString((char)unicodeChar)); } } } else if (event.getAction() == KeyEvent.ACTION_DOWN) { // TODO(aurimas): remove this workaround when crbug.com/278584 is fixed. if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { beginBatchEdit(); finishComposingText(); mImeAdapter.translateAndSendNativeEvents(event); endBatchEdit(); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) { return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) { return true; } } mImeAdapter.translateAndSendNativeEvents(event); return true; }
Example 7
Source File: AdapterInputConnection.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * @see BaseInputConnection#sendKeyEvent(android.view.KeyEvent) */ @Override public boolean sendKeyEvent(KeyEvent event) { if (DEBUG) { Log.w(TAG, "sendKeyEvent [" + event.getAction() + "] [" + event.getKeyCode() + "]"); } // If this is a key-up, and backspace/del or if the key has a character representation, // need to update the underlying Editable (i.e. the local representation of the text // being edited). if (event.getAction() == KeyEvent.ACTION_UP) { if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) { deleteSurroundingText(1, 0); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) { deleteSurroundingText(0, 1); return true; } else { int unicodeChar = event.getUnicodeChar(); if (unicodeChar != 0) { Editable editable = getEditable(); int selectionStart = Selection.getSelectionStart(editable); int selectionEnd = Selection.getSelectionEnd(editable); if (selectionStart > selectionEnd) { int temp = selectionStart; selectionStart = selectionEnd; selectionEnd = temp; } editable.replace(selectionStart, selectionEnd, Character.toString((char)unicodeChar)); } } } else if (event.getAction() == KeyEvent.ACTION_DOWN) { // TODO(aurimas): remove this workaround when crbug.com/278584 is fixed. if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { beginBatchEdit(); finishComposingText(); mImeAdapter.translateAndSendNativeEvents(event); endBatchEdit(); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) { return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) { return true; } } mImeAdapter.translateAndSendNativeEvents(event); return true; }