Enable Cursor and long tap copy/paste feature in EditText view for custom Keyboard

Viewed 8

I developed my own keyboard for typing Urdu text, but there is an issue when I disable the default soft keyboard then.

  1. Cursor on EditText will disappear.
  2. Unable to Tab on EditText and remove the word from mid of EditText.
  3. When I enable the cursor on EditText, then both keyboards (layoutKeyboard and default soft keyboard) show at the same time.

I use this code to hide the default keyboard and enable it on the keyboard.

private void setKeysBoard(boolean MyKeyBoardEnabled) {
    if (MyKeyBoardEnabled) {
        hideSoftKeyboard();
        search.setCursorVisible(true); 
        search.setFocusable(true); 
        search.setFocusableInTouchMode(false);  
        findViewById(R.id.mykeyboard).setVisibility(View.VISIBLE); 
    } else {
        findViewById(R.id.mykeyboard).setVisibility(View.GONE);
        search.requestFocus();
        search.setCursorVisible(true);
        search.setFocusable(true);
        search.setFocusableInTouchMode(true);
        }
   }
        
private void hideSoftKeyboard() {
    View view = this.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            if (android.os.Build.VERSION.SDK_INT >= 28) {
                        imm.hideSoftInputFromWindow(findViewById(android.R.id.content).getWindowToken(), 0);
            } else imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
        view.clearFocus();
    }
}   

I want to show my own keyboard with the cursor and copy/paste features as well. I also disabled my keyboard and enabled the default one and how to code for it.

enter image description here

0 Answers
Related