Predictive back gesture does not fire keyUp event
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 25.4k
- Forks
- 6.5k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 5
Description
Describe the bug
PR #7429 added support for predictive back gestures. That is a special way of triggering the back key via a gesture on Android. In contrast to the previous implementation - and my expectation on how it would work - it does not fire a keyUp event.
From my understanding the solution would be to also fire a KEY_UP event in the OnBackInvokedCallback.onBackInvoked() implementation:
https://github.com/libgdx/libgdx/blob/32eb91a76e7d8bef051cf5a6c88153cc6dd88395/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/DefaultAndroidInput.java#L1420-L1425
Reproduction
The main difficulty may be to know if your device is even using predictive back gestures.
Here's a setup to create a test bed:
Gdx.input.setCatchKey(Input.Keys.BACK, true)
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyDown(int keycode) {
Gdx.app.debug("input", "keyDown: " + Input.Keys.toString(keycode));
return true;
}
@Override
public boolean keyUp(int keycode) {
Gdx.app.debug("input", "keyUp: " + Input.Keys.toString(keycode));
return true;
}
});
On my test device (only using gesture back button) it outputs:
[input] keyDown: Back
[input] keyDown: Back
[input] keyDown: Back
...
While I would expect it to output:
[input] keyDown: Back
[input] keyUp: Back
[input] keyDown: Back
[input] keyUp: Back
[input] keyDown: Back
[input] keyUp: Back
...
version
1.13.0+
Affected platforms
- Android
- iOS
- HTML/GWT
- Windows
- Linux
- macOS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/DefaultAndroidInput.java at the OnBackInvokedCallback.onBackInvoked() implementation linked in the issue. Use the provided InputAdapter reproduction with an Android device using gesture navigation, and verify that each predictive back gesture produces a keyDown followed by a keyUp for Back.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100