Skip to content

Commit

Permalink
fix long press clipboard key
Browse files Browse the repository at this point in the history
  • Loading branch information
Sesow29 committed Apr 29, 2024
1 parent d173087 commit 5da2789
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,21 @@ private void handleConsumedEvent(final Event event, final InputTransaction input
}
}

/**
* Handles the action of pasting content from the clipboard.
* Retrieves content from the clipboard history manager and commits it to the input connection.
* Sets a flag in the input transaction to indicate that the operation has affected the input contents.
*
* @param inputTransaction The transaction in progress.
*/
private void handleClipboardPaste(final InputTransaction inputTransaction) {
final CharSequence clipboardContent = mLatinIME.getClipboardHistoryManager().retrieveClipboardContent();
if (!TextUtils.isEmpty(clipboardContent)) {
mConnection.commitText(clipboardContent, 1);
inputTransaction.setDidAffectContents();
}
}

/**
* Handle a functional key event.
* <p>
Expand Down Expand Up @@ -685,14 +700,12 @@ private void handleFunctionalEvent(final Event event, final InputTransaction inp
// is being handled in {@link KeyboardState#onEvent(Event,int)}.
// If disabled, current clipboard content is committed.
if (!inputTransaction.getMSettingsValues().mClipboardHistoryEnabled) {
final CharSequence content = mLatinIME.getClipboardHistoryManager()
.retrieveClipboardContent();
if (!TextUtils.isEmpty(content)) {
mConnection.commitText(content, 1);
inputTransaction.setDidAffectContents();
}
handleClipboardPaste(inputTransaction);
}
break;
case KeyCode.CLIPBOARD_PASTE:
handleClipboardPaste(inputTransaction);
break;
case KeyCode.SHIFT_ENTER:
final Event tmpEvent = Event.createSoftwareKeypressEvent(Constants.CODE_ENTER,
event.getMKeyCode(), event.getMX(), event.getMY(), event.isKeyRepeat());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fun getCodeForToolbarKeyLongClick(key: ToolbarKey) = when (key) {
REDO -> KeyCode.UNDO
COPY -> KeyCode.CLIPBOARD_COPY_ALL
SELECT_WORD -> KeyCode.CLIPBOARD_SELECT_ALL
CLIPBOARD -> KeyCode.CLIPBOARD_COPY
CLIPBOARD -> KeyCode.CLIPBOARD_PASTE
else -> KeyCode.UNSPECIFIED
}

Expand Down

0 comments on commit 5da2789

Please sign in to comment.