TextFiction
TextFiction copied to clipboard
Physical enter key press goes through twice
On a Motorola Photon Q with Cyanogenmod 13 when I press enter it sends the command and a blank command so I always get a 'beg your pardon" response.
I'm uploading a screenshot showing it.
The beg your pardon response, while annoying, should not disrupt play.
Does this happen with commands you enter via the icons? For example, press the eye icon and then the submit icon represented by an arrow or paper airplane to the right of "what next?" input prompt. In this case does the error occur, or is it primarily only via keyboard input?
Hi, afair, this only happens with bluetooth keyboards. I suspect they send a keypress and a submit event. But I don't have the hardware to test that.
Am Dienstag, den 27.12.2016, 14:23 -0800 schrieb Jerimee Richir:
The beg your pardon response, while annoying, should not disrupt play.
Does this happen with commands you enter via the icons? For example, press the eye icon and then the submit icon represented by an arrow or paper airplane to the right of "what next?" input prompt. In this case does the error occur, or is it primarily only via keyboard input?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
It only occurs when using a physical keyboard (in this case not bluetooth, but attached). Also, you're right, the games can be played it's just an annoyance.
this only happens with bluetooth keyboards. I suspect they send a keypress and a submit event. But I don't have the hardware to test that.
@onyxbits it happens in the Android emulator too, which emulates a Bluetooth/USB keyboard if you choose to "turn off" the onscreen keyboard. - So you don't need hardware to reproduce the problem.
I suspect InputFragment.java line 261 https://github.com/onyxbits/TextFiction/blob/master/src/de/onyxbits/textfiction/input/InputFragment.java#L261 - method onEditorAction is being called twice with a physical [enter] key. Once for KeyEvent.ACTION_UP and one for KeyEvent.ACTION_DOWN
I suggest ignoring the UP, as it's faster to send the DOWN.
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// Issue #17 https://github.com/onyxbits/TextFiction/issues/17
if (event != null) {
if (event.getAction() == KeyEvent.ACTION_UP) {
// skip, we only want the key down
return false;
}
}
executeCommand();
return !autoCollapse;
}
In addition to my previous comment, I also observed that focus seems to change away from the EditText after pressing [enter] key on a hard keyboard. This means you can't quickly type line after line.
Pressing the graphic arrow image at the end of the line does not steal focus from the TextEdit - but hard keyboard [enter] does. I spent over 45 minutes trying to figure out why... but ultimately punted to a hack to restore focus.
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// Issue #17 https://github.com/onyxbits/TextFiction/issues/17
if (event != null) {
if (event.getAction() == KeyEvent.ACTION_UP) {
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
// Direct requestFocus() does not seem to change behavior. Posting a Runnable
// without delay seems to restore focus on hard keyboard use.
cmdLine.post(new Runnable() {
@Override
public void run() {
cmdLine.requestFocus();
}
});
}
// skip sending to fiction engine, we only want the key down.
return false;
}
}
executeCommand();
return !autoCollapse;
}
any possibility of a fix for this?