From 60b01927abed9479bed5fdbb268f049cfe609aea Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 15 Mar 2025 16:13:16 +0100 Subject: Selection mode (#913) * Selection mode: Space to cancel the selection This adds the "selection mode", which is activated when text is selected in the text box. The selection mode is exited when the selection is cleared. While the selection mode is activated, the Space and Esc keys are modified into the "selection cancel" key, which remove the selection without changing the text. The space bar is otherwise easy to type by accident during a selection and causes the selected text to be deleted. * Selection mode: Move each ends of selection separately with slider When the selection mode is activated, the space bar sliders change how they affect the selection: - The left side of the slider moves the left position of the selection. To shrink the selection from the left side, the slider must be activated by sliding to the left, extending the selection temporarilly, then by sliding to the right. - The right side of the slider affects the right position if the selection.--- srcs/juloo.keyboard2/Keyboard2.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'srcs/juloo.keyboard2/Keyboard2.java') diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 02c062a..9e54aaf 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -362,6 +362,8 @@ public class Keyboard2 extends InputMethodService { super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd, candidatesStart, candidatesEnd); _keyeventhandler.selection_updated(oldSelStart, newSelStart); + if ((oldSelStart == oldSelEnd) != (newSelStart == newSelEnd)) + _keyboardView.set_selection_state(newSelStart != newSelEnd); } @Override @@ -480,6 +482,11 @@ public class Keyboard2 extends InputMethodService _keyboardView.set_compose_pending(pending); } + public void selection_state_changed(boolean selection_is_ongoing) + { + _keyboardView.set_selection_state(selection_is_ongoing); + } + public InputConnection getCurrentInputConnection() { return Keyboard2.this.getCurrentInputConnection(); -- cgit v1.2.3