mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-16 23:12:47 +00:00
make space bar trackpad work in apps that always report empty text
This commit is contained in:
parent
57423626d3
commit
f471cf81ed
1 changed files with 25 additions and 9 deletions
|
@ -1405,29 +1405,45 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
|
||||
@Override
|
||||
public void onMovePointer(int steps) {
|
||||
if (steps == 0) return;
|
||||
// for RTL languages we want to invert pointer movement
|
||||
if (mRichImm.getCurrentSubtype().isRtlSubtype())
|
||||
steps = -steps;
|
||||
|
||||
final int moveSteps;
|
||||
if (steps < 0) {
|
||||
int availableCharacters = mInputLogic.mConnection.getTextBeforeCursor(64, 0).length();
|
||||
steps = availableCharacters < -steps ? -availableCharacters : steps;
|
||||
moveSteps = availableCharacters < -steps ? -availableCharacters : steps;
|
||||
if (moveSteps == 0) {
|
||||
// some apps don't return any text via input connection, and the cursor can't be moved
|
||||
// we fall back to virtually pressing the left/right key one or more times instead
|
||||
while (steps != 0) {
|
||||
onCodeInput(Constants.CODE_LEFT, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false);
|
||||
++steps;
|
||||
}
|
||||
else if (steps > 0) {
|
||||
int availableCharacters = mInputLogic.mConnection.getTextAfterCursor(64, 0).length();
|
||||
steps = Math.min(availableCharacters, steps);
|
||||
} else
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
int availableCharacters = mInputLogic.mConnection.getTextAfterCursor(64, 0).length();
|
||||
moveSteps = Math.min(availableCharacters, steps);
|
||||
if (moveSteps == 0) {
|
||||
while (steps != 0) {
|
||||
onCodeInput(Constants.CODE_RIGHT, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false);
|
||||
--steps;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mInputLogic.moveCursorByAndReturnIfInsideComposingWord(steps)) {
|
||||
if (mInputLogic.moveCursorByAndReturnIfInsideComposingWord(moveSteps)) {
|
||||
// no need to finish input and restart suggestions if we're still in the word
|
||||
// this is a noticeable performance improvement
|
||||
int newPosition = mInputLogic.mConnection.mExpectedSelStart + steps;
|
||||
int newPosition = mInputLogic.mConnection.mExpectedSelStart + moveSteps;
|
||||
mInputLogic.mConnection.setSelection(newPosition, newPosition);
|
||||
return;
|
||||
}
|
||||
mInputLogic.finishInput();
|
||||
int newPosition = mInputLogic.mConnection.mExpectedSelStart + steps;
|
||||
int newPosition = mInputLogic.mConnection.mExpectedSelStart + moveSteps;
|
||||
mInputLogic.mConnection.setSelection(newPosition, newPosition);
|
||||
mInputLogic.restartSuggestionsOnWordTouchedByCursor(mSettings.getCurrent(), mKeyboardSwitcher.getCurrentKeyboardScriptId());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue