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

fix backspace on android for AOSP-based keyboards #2232

Merged
merged 4 commits into from May 27, 2021
Merged

fix backspace on android for AOSP-based keyboards #2232

merged 4 commits into from May 27, 2021

Conversation

howeyc
Copy link
Contributor

@howeyc howeyc commented May 9, 2021

Gboard always sends backspace events, however, other keyboards only send
or enable the backspace based on the state of the textentry. Also, some
don't send the event, but instead modify the textentry text itself.

This edits the entry to always have some text, a zero. This way the
keyboards will be able to edit/backspace characters. The textChanged
then sends a backspace Key Event to the Go code.

In the case of using a keyboard (such as Gboard) that sends its own
backspace event, we need a way to stop processing of two deletes (the
one Gboard sends, and the one textChanged sends). A backspaceDelay timer
is used to only process backspaces a certain time (50ms) apart.

Fixes #1941

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Issue #1941

Gboard always sends backspace events, however, other keyboards only send
or enable the backspace based on the state of the textentry. Also, some
don't send the event, but instead modify the textentry text itself.

This edits the entry to always show some text, a zero. This way the
keyboards kill be able to edit/backspace characters. The textChanged
then sends a backspace Key Event to the Go code.

In the case of using a keyboard (such as Gboard) that sends its own
backspace event, we need a way to stop processing of two deletes (the
one Gboard sends, and the one textChanged sends). A backspaceDelay timer
is used to only process backspaces a certain time (50ms) apart.
@andydotxyz
Copy link
Member

This edits the entry to always have some text, a zero. This way the
keyboards will be able to edit/backspace characters.

What happens if you want to backspace twice?
I think the "right thing" to do is to set the content on the hidden entry as the real content - would that be possible/desirable?

@howeyc
Copy link
Contributor Author

howeyc commented May 10, 2021

What happens if you want to backspace twice?

After processing a backspace I put another zero in there. :)

I think the "right thing" to do is to set the content on the hidden
entry as the real content - would that be possible/desirable?

Probably, but that's quite a few layers to sift through to push/pop the content back and forth, from what I can tell. I wasn't sure how to even do that. So I did the quick and dirty way.

@andydotxyz
Copy link
Member

Good answers thanks, will try this out :)

@stuartmscott
Copy link
Member

What if the user presses and holds backspace to delete a block of text?

@howeyc
Copy link
Contributor Author

howeyc commented May 10, 2021

What if the user presses and holds backspace to delete a block of text?

Works just fine, for me anyway. You see the characters delete as you would expect. I've been testing with the POC code in the linked issue with both Gboard and Openboard.

@andydotxyz
Copy link
Member

I have managed to install the keyboard and see that this has improved things.
However the following still seems to be broken:

  • enter some text in a field
  • move to a different field
  • go back to the original one
  • backspace does not work here

@howeyc
Copy link
Contributor Author

howeyc commented May 13, 2021

Interesting, I'll see if I can figure it out.

I noticed that if you click to another part of an entry, to move the position of the cursor, it stops working as well. So I have to click off an entry, to get nothing selected, then click back onto an entry.

Similar to multiple entry issue, need to click off entry, then click the other one. Can't directly switch cursor from one entry to another.

Something to do with how/when the android edittext gets setup maybe.

@howeyc
Copy link
Contributor Author

howeyc commented May 14, 2021

Ignoring a request for keyboard when it's already up seems to allow for switching between fyne entry fields. Also fixes the issue I saw where you click to move the cursor within an entry.

@howeyc
Copy link
Contributor Author

howeyc commented May 14, 2021

If this works for you I will clean it up to be proper (a pull against mobile repo), and this updating the go.mod and such. Plus it looks like there's conflict I need to resolve.

Let me know, thanks.

@howeyc
Copy link
Contributor Author

howeyc commented May 19, 2021

merged latest develop branch to fix merge conflict

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think this functions well now thanks @howeyc, I'll check out the mobile / merged PRs once they are ready.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks

@andydotxyz andydotxyz merged commit dcfaf76 into fyne-io:develop May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants