mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-06-25 04:02:02 +02:00
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.
This commit is contained in:
parent
c6da6d6ab5
commit
9d12981b34
@ -234,9 +234,9 @@ public final class KeyEventHandler
|
|||||||
{
|
{
|
||||||
switch (ev)
|
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 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 SELECT_ALL: send_context_menu_action(android.R.id.selectAll); break;
|
||||||
case SHARE: send_context_menu_action(android.R.id.shareText); break;
|
case SHARE: send_context_menu_action(android.R.id.shareText); break;
|
||||||
case PASTE_PLAIN: send_context_menu_action(android.R.id.pasteAsPlainText); 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);
|
_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 static interface IReceiver
|
||||||
{
|
{
|
||||||
public void handle_event_key(KeyValue.Event ev);
|
public void handle_event_key(KeyValue.Event ev);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user