Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: key events not fired for predictive keyboards #38179

Open
andydotxyz opened this issue Mar 31, 2020 · 4 comments
Open

x/mobile: key events not fired for predictive keyboards #38179

andydotxyz opened this issue Mar 31, 2020 · 4 comments

Comments

@andydotxyz
Copy link
Contributor

@andydotxyz andydotxyz commented Mar 31, 2020

On a Samsing Galaxy S10, running Android 10 (this was not an issue with the keyboard they shipped in Android 9) key events are no longer fired when the (default) predictive text is turned on.
Some other apps, such as Termux (termux/termux-app#686) report that words appear after space/enter etc - however that is not true for gomobile. Each time a word should display a single "unknown key code" event is fired and no characters.

What version of Go are you using (go version)?

1.12, 1.13, 1.14

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

I think the environment on the Android phone is most relevant, but I don't know what to provide.
Code works fine on older keyboards, or if you turn off the predictive text

What did you do?

  • run a gomobile app on Galaxy S10 with Android 10, cause a keyboard to appear (I used fyne_demo app).
  • type "hello " (ending in a space) and see that only a space is added to the entry.
  • type "g " and you will see that "g" is shown followed by a space.

What did you expect to see?

I want to see characters as they are entered. There are various docs about how to disable prediction (such as https://developer.android.com/reference/android/text/InputType#TYPE_NULL) but I cannot figure out how to set those options in a default gomobile app, as the root view does not seem to be configurable in GoNativeActivity.java.

What did you see instead?

(as above)

@andydotxyz
Copy link
Contributor Author

@andydotxyz andydotxyz commented Mar 31, 2020

I have managed to force disabling of prediction by using a hidden EditText and setting the input type:
textEdit.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);

However this does not generate any key events when typing.

@andydotxyz
Copy link
Contributor Author

@andydotxyz andydotxyz commented Mar 31, 2020

The only progress I have made is using the EditText workaround, pack one into the view hierarchy, then you can add a change watcher:

mTextEdit.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(...) {
// here we can get the current state of the text field...
});

Unfortunately I cannot figure out how to reverse-engineer key events, it is reporting the current state. But it's a start...

@andydotxyz
Copy link
Contributor Author

@andydotxyz andydotxyz commented Mar 31, 2020

I followed that line of thought for a while but then realised that normal keyboard will get double-events because they get keys as well.
This feels like a very complex situation. Any experts got thoughts? :)

@andybons andybons changed the title x/mobile: Key events not fired for predictive keyboards x/mobile: key events not fired for predictive keyboards Mar 31, 2020
@andybons
Copy link
Member

@andybons andybons commented Mar 31, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.