Example usage for android.view.inputmethod InputConnection performContextMenuAction

List of usage examples for android.view.inputmethod InputConnection performContextMenuAction

Introduction

In this page you can find the example usage for android.view.inputmethod InputConnection performContextMenuAction.

Prototype

boolean performContextMenuAction(int id);

Source Link

Document

Perform a context menu action on the field.

Usage

From source file:com.volosyukivan.WiFiInputMethod.java

private void paste(InputConnection conn) {
    conn.performContextMenuAction(android.R.id.paste);
}

From source file:com.volosyukivan.WiFiInputMethod.java

private void copy(InputConnection conn) {
    conn.performContextMenuAction(android.R.id.copy);
}

From source file:com.volosyukivan.WiFiInputMethod.java

private void cut(InputConnection conn) {
    conn.performContextMenuAction(android.R.id.cut);
}

From source file:org.kde.kdeconnect.Plugins.RemoteKeyboardPlugin.RemoteKeyboardPlugin.java

private boolean handleVisibleKey(String key, boolean shift, boolean ctrl, boolean alt) {
    //        Log.d("RemoteKeyboardPlugin", "Handling visible key " + key + " shift=" + shift + " ctrl=" + ctrl + " alt=" + alt + " " + key.equalsIgnoreCase("c") + " " + key.length());

    if (key.isEmpty())
        return false;

    InputConnection inputConn = RemoteKeyboardService.instance.getCurrentInputConnection();
    if (inputConn == null)
        return false;

    // ctrl+c/v/x
    if (key.equalsIgnoreCase("c") && ctrl) {
        return inputConn.performContextMenuAction(android.R.id.copy);
    } else if (key.equalsIgnoreCase("v") && ctrl)
        return inputConn.performContextMenuAction(android.R.id.paste);
    else if (key.equalsIgnoreCase("x") && ctrl)
        return inputConn.performContextMenuAction(android.R.id.cut);
    else if (key.equalsIgnoreCase("a") && ctrl)
        return inputConn.performContextMenuAction(android.R.id.selectAll);

    //        Log.d("RemoteKeyboardPlugin", "Committing visible key '" + key + "'");
    inputConn.commitText(key, key.length());
    return true;//from   ww w  . j  a v  a 2 s.  c  o  m
}