mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-01 20:32:15 +00:00
workaround for page start / page end toolbar keys not working in compose text fields
fixes GH-1477
This commit is contained in:
parent
91b177d204
commit
366ee5ae28
1 changed files with 17 additions and 0 deletions
|
@ -773,10 +773,27 @@ public final class InputLogic {
|
|||
KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, KeyEvent.META_CTRL_ON);
|
||||
break;
|
||||
case KeyCode.MOVE_START_OF_PAGE:
|
||||
final int selectionEnd = mConnection.getExpectedSelectionEnd();
|
||||
sendDownUpKeyEventWithMetaState(KeyEvent.KEYCODE_MOVE_HOME, KeyEvent.META_CTRL_ON);
|
||||
if (mConnection.getExpectedSelectionStart() > 0 && mConnection.getExpectedSelectionEnd() == selectionEnd) {
|
||||
// unchanged, and we're not at the top -> try a different method (necessary for compose fields)
|
||||
mConnection.setSelection(0, 0);
|
||||
}
|
||||
break;
|
||||
case KeyCode.MOVE_END_OF_PAGE:
|
||||
final int selectionStart = mConnection.getExpectedSelectionEnd();
|
||||
sendDownUpKeyEventWithMetaState(KeyEvent.KEYCODE_MOVE_END, KeyEvent.META_CTRL_ON);
|
||||
if (mConnection.getExpectedSelectionStart() == selectionStart) {
|
||||
// unchanged, try fallback e.g. for compose fields that don't care about ctrl + end
|
||||
// we just move to a very large index, and hope the field is prepared to deal with this
|
||||
// getting the actual length of the text for setting the correct position can be tricky for some apps...
|
||||
try {
|
||||
mConnection.setSelection(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
} catch (Exception e) {
|
||||
// better catch potential errors and just do nothing in this case
|
||||
Log.i(TAG, "error when trying to move cursor to last position: " + e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KeyCode.UNDO:
|
||||
sendDownUpKeyEventWithMetaState(KeyEvent.KEYCODE_Z, KeyEvent.META_CTRL_ON);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue