MentionEditText icon indicating copy to clipboard operation
MentionEditText copied to clipboard

有部分机型不能删除 @** 的bug

Open hyccode opened this issue 6 years ago • 0 comments

@Override public boolean sendKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_DEL) { int selectionStart = editText.getSelectionStart(); int selectionEnd = editText.getSelectionEnd(); Range closestRange = getRangeOfClosestMentionString(selectionStart, selectionEnd); if (closestRange == null) { mIsSelected = false; return super.sendKeyEvent(event); } //if mention string has been selected or the cursor is at the beginning of mention string, just use default action(delete) if (mIsSelected || selectionStart == closestRange.from) { mIsSelected = false; return super.sendKeyEvent(event); } else { //select the mention string mIsSelected = true; mLastSelectedRange = closestRange; // setSelection(closestRange.to,closestRange.from); setSelection(closestRange.from,closestRange.to); } return true; } return super.sendKeyEvent(event); }

hyccode avatar Dec 25 '18 04:12 hyccode