Skip to content

Commit

Permalink
send key event instead of text when entering numbers in a non-text field
Browse files Browse the repository at this point in the history
fixes #585
  • Loading branch information
Helium314 committed Mar 24, 2024
1 parent 7adeb40 commit f07c6d9
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import android.graphics.Color;
import android.os.SystemClock;
import android.text.InputType;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
Expand Down Expand Up @@ -968,6 +969,12 @@ private void handleNonSeparatorEvent(final Event event, final SettingsValues set

if (swapWeakSpace && trySwapSwapperAndSpace(event, inputTransaction)) {
mSpaceState = SpaceState.WEAK;
} else if ((settingsValues.mInputAttributes.mInputType & InputType.TYPE_MASK_CLASS) != InputType.TYPE_CLASS_TEXT
&& codePoint >= '0' && codePoint <= '9') {
// weird issue when committing text: https://github.com/Helium314/HeliBoard/issues/585
// but at the same time we don't always want to do it for numbers because it might interfere with url detection
// todo: consider always using sendDownUpKeyEvent for non-text-inputType
sendDownUpKeyEvent(codePoint - '0' + KeyEvent.KEYCODE_0);
} else {
mConnection.commitCodePoint(codePoint);
}
Expand Down

0 comments on commit f07c6d9

Please sign in to comment.