mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 13:49:13 +00:00
make arrow keys repeatable (#932)
only applies to keyboard keys, not in toolbar
This commit is contained in:
parent
74571a3202
commit
a92d108444
4 changed files with 24 additions and 7 deletions
|
@ -1171,13 +1171,17 @@ public class Key implements Comparable<Key> {
|
||||||
if (mCode <= Constants.CODE_SPACE && mCode != KeyCode.MULTIPLE_CODE_POINTS && mIconName == null)
|
if (mCode <= Constants.CODE_SPACE && mCode != KeyCode.MULTIPLE_CODE_POINTS && mIconName == null)
|
||||||
actionFlags |= ACTION_FLAGS_NO_KEY_PREVIEW;
|
actionFlags |= ACTION_FLAGS_NO_KEY_PREVIEW;
|
||||||
switch (mCode) {
|
switch (mCode) {
|
||||||
case KeyCode.DELETE, KeyCode.SHIFT, Constants.CODE_ENTER, KeyCode.SHIFT_ENTER, KeyCode.ALPHA, Constants.CODE_SPACE, KeyCode.NUMPAD,
|
case KeyCode.DELETE, KeyCode.ARROW_LEFT, KeyCode.ARROW_RIGHT, KeyCode.ARROW_UP, KeyCode.ARROW_DOWN:
|
||||||
KeyCode.SYMBOL, KeyCode.SYMBOL_ALPHA, KeyCode.LANGUAGE_SWITCH, KeyCode.EMOJI, KeyCode.CLIPBOARD -> actionFlags |= ACTION_FLAGS_NO_KEY_PREVIEW; // no preview even if icon!
|
// repeating is disabled if a key is configured with pop-ups
|
||||||
|
if (mPopupKeys == null)
|
||||||
|
actionFlags |= ACTION_FLAGS_IS_REPEATABLE;
|
||||||
|
// fallthrough
|
||||||
|
case KeyCode.SHIFT, Constants.CODE_ENTER, KeyCode.SHIFT_ENTER, KeyCode.ALPHA, Constants.CODE_SPACE, KeyCode.NUMPAD,
|
||||||
|
KeyCode.SYMBOL, KeyCode.SYMBOL_ALPHA, KeyCode.LANGUAGE_SWITCH, KeyCode.EMOJI, KeyCode.CLIPBOARD:
|
||||||
|
actionFlags |= ACTION_FLAGS_NO_KEY_PREVIEW; // no preview even if icon!
|
||||||
}
|
}
|
||||||
if (mCode == KeyCode.SETTINGS || mCode == KeyCode.LANGUAGE_SWITCH)
|
if (mCode == KeyCode.SETTINGS || mCode == KeyCode.LANGUAGE_SWITCH)
|
||||||
actionFlags |= ACTION_FLAGS_ALT_CODE_WHILE_TYPING;
|
actionFlags |= ACTION_FLAGS_ALT_CODE_WHILE_TYPING;
|
||||||
if (mCode == KeyCode.DELETE)
|
|
||||||
actionFlags |= ACTION_FLAGS_IS_REPEATABLE;
|
|
||||||
mActionFlags = actionFlags;
|
mActionFlags = actionFlags;
|
||||||
|
|
||||||
final int altCodeInAttr; // settings and language switch keys have alt code space, all others nothing
|
final int altCodeInAttr; // settings and language switch keys have alt code space, all others nothing
|
||||||
|
|
|
@ -1731,9 +1731,16 @@ public class LatinIME extends InputMethodService implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (repeatCount > 0) {
|
if (repeatCount > 0) {
|
||||||
if (code == KeyCode.DELETE && !mInputLogic.mConnection.canDeleteCharacters()) {
|
// No need to feedback when repeat delete/cursor keys will have no effect.
|
||||||
// No need to feedback when repeat delete key will have no effect.
|
switch (code) {
|
||||||
|
case KeyCode.DELETE, KeyCode.ARROW_LEFT, KeyCode.ARROW_UP:
|
||||||
|
if (!mInputLogic.mConnection.canDeleteCharacters())
|
||||||
return;
|
return;
|
||||||
|
break;
|
||||||
|
case KeyCode.ARROW_RIGHT, KeyCode.ARROW_DOWN:
|
||||||
|
if (!mInputLogic.mConnection.canForwardDeleteCharacters())
|
||||||
|
return;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// TODO: Use event time that the last feedback has been generated instead of relying on
|
// TODO: Use event time that the last feedback has been generated instead of relying on
|
||||||
// a repeat count to thin out feedback.
|
// a repeat count to thin out feedback.
|
||||||
|
|
|
@ -363,6 +363,11 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
||||||
return mExpectedSelStart > 0;
|
return mExpectedSelStart > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canForwardDeleteCharacters() {
|
||||||
|
final CharSequence after = getTextAfterCursor(1, 0);
|
||||||
|
return !TextUtils.isEmpty(after);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the caps modes we should be in after this specific string.
|
* Gets the caps modes we should be in after this specific string.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -62,6 +62,7 @@ If the layout has exactly 2 keys in the bottom row, these keys will replace comm
|
||||||
* `popup`: list of keys to add in the popup, e.g. `"label": ")", "popup": {"relevant": [{ "label": "." }]}` is a `)` key with a `.` popup
|
* `popup`: list of keys to add in the popup, e.g. `"label": ")", "popup": {"relevant": [{ "label": "." }]}` is a `)` key with a `.` popup
|
||||||
* Note that in popup keys, properties are ignored with the exception of `$`, `code`, `codePoints`, and `label`
|
* Note that in popup keys, properties are ignored with the exception of `$`, `code`, `codePoints`, and `label`
|
||||||
* When specifying a _selector_ key class in a popup key, it will be evaluated correctly (e.g. for changing popups dependent on shift state)
|
* When specifying a _selector_ key class in a popup key, it will be evaluated correctly (e.g. for changing popups dependent on shift state)
|
||||||
|
* If popups are added to repeating keys (e.g. delete, arrow keys), repetition will be disabled.
|
||||||
* `width`: width of the key in units of screen width, e.g. a key with `"width": 0.1` has a width of 10% of the screen, defaults to `0`
|
* `width`: width of the key in units of screen width, e.g. a key with `"width": 0.1` has a width of 10% of the screen, defaults to `0`
|
||||||
* A special value is `-1`, which means the key expands to the available space not already used by other keys (e.g. the space bar)
|
* A special value is `-1`, which means the key expands to the available space not already used by other keys (e.g. the space bar)
|
||||||
* `0` is interpreted as follows
|
* `0` is interpreted as follows
|
||||||
|
|
Loading…
Add table
Reference in a new issue