mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 07:22:45 +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
|
@Override
|
||||||
public void onMovePointer(int steps) {
|
public void onMovePointer(int steps) {
|
||||||
|
if (steps == 0) return;
|
||||||
// for RTL languages we want to invert pointer movement
|
// for RTL languages we want to invert pointer movement
|
||||||
if (mRichImm.getCurrentSubtype().isRtlSubtype())
|
if (mRichImm.getCurrentSubtype().isRtlSubtype())
|
||||||
steps = -steps;
|
steps = -steps;
|
||||||
|
|
||||||
|
final int moveSteps;
|
||||||
if (steps < 0) {
|
if (steps < 0) {
|
||||||
int availableCharacters = mInputLogic.mConnection.getTextBeforeCursor(64, 0).length();
|
int availableCharacters = mInputLogic.mConnection.getTextBeforeCursor(64, 0).length();
|
||||||
steps = availableCharacters < -steps ? -availableCharacters : steps;
|
moveSteps = availableCharacters < -steps ? -availableCharacters : steps;
|
||||||
}
|
if (moveSteps == 0) {
|
||||||
else if (steps > 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;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
int availableCharacters = mInputLogic.mConnection.getTextAfterCursor(64, 0).length();
|
int availableCharacters = mInputLogic.mConnection.getTextAfterCursor(64, 0).length();
|
||||||
steps = Math.min(availableCharacters, steps);
|
moveSteps = Math.min(availableCharacters, steps);
|
||||||
} else
|
if (moveSteps == 0) {
|
||||||
return;
|
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
|
// no need to finish input and restart suggestions if we're still in the word
|
||||||
// this is a noticeable performance improvement
|
// this is a noticeable performance improvement
|
||||||
int newPosition = mInputLogic.mConnection.mExpectedSelStart + steps;
|
int newPosition = mInputLogic.mConnection.mExpectedSelStart + moveSteps;
|
||||||
mInputLogic.mConnection.setSelection(newPosition, newPosition);
|
mInputLogic.mConnection.setSelection(newPosition, newPosition);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mInputLogic.finishInput();
|
mInputLogic.finishInput();
|
||||||
int newPosition = mInputLogic.mConnection.mExpectedSelStart + steps;
|
int newPosition = mInputLogic.mConnection.mExpectedSelStart + moveSteps;
|
||||||
mInputLogic.mConnection.setSelection(newPosition, newPosition);
|
mInputLogic.mConnection.setSelection(newPosition, newPosition);
|
||||||
mInputLogic.restartSuggestionsOnWordTouchedByCursor(mSettings.getCurrent(), mKeyboardSwitcher.getCurrentKeyboardScriptId());
|
mInputLogic.restartSuggestionsOnWordTouchedByCursor(mSettings.getCurrent(), mKeyboardSwitcher.getCurrentKeyboardScriptId());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue