diff options
| author | alotbsol555 | 2025-06-21 22:15:22 +0200 |
|---|---|---|
| committer | GitHub | 2025-06-21 22:15:22 +0200 |
| commit | 9d12981b3478a947fc731f78de3f5cdeeb20a676 (patch) | |
| tree | 30cfd8a3929376166a2407db25d5958caf20d6b6 /srcs | |
| parent | c6da6d6ab55f694d4c6a393c4fdb45f6dde7c873 (diff) | |
| download | unexpected-keyboard-9d12981b3478a947fc731f78de3f5cdeeb20a676.tar.gz unexpected-keyboard-9d12981b3478a947fc731f78de3f5cdeeb20a676.zip | |
cut and copy with built in keys only if text is selected (#1019)
cut and copy with built in keys only if text is selected to keep existing clipboard content. does not work for key combinations like ctrl+x or ctrl+c.
Diffstat (limited to 'srcs')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyEventHandler.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index cde26e1..3c95f3d 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -234,9 +234,9 @@ public final class KeyEventHandler { switch (ev) { - case COPY: send_context_menu_action(android.R.id.copy); break; + case COPY: if(is_selection_not_empty()) send_context_menu_action(android.R.id.copy); break; case PASTE: send_context_menu_action(android.R.id.paste); break; - case CUT: send_context_menu_action(android.R.id.cut); break; + case CUT: if(is_selection_not_empty()) send_context_menu_action(android.R.id.cut); break; case SELECT_ALL: send_context_menu_action(android.R.id.selectAll); break; case SHARE: send_context_menu_action(android.R.id.shareText); break; case PASTE_PLAIN: send_context_menu_action(android.R.id.pasteAsPlainText); break; @@ -466,6 +466,13 @@ public final class KeyEventHandler _recv.selection_state_changed(false); } + boolean is_selection_not_empty() + { + InputConnection conn = _recv.getCurrentInputConnection(); + if (conn == null) return false; + return (conn.getSelectedText(0) != null); + } + public static interface IReceiver { public void handle_event_key(KeyValue.Event ev); |
