fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.16k stars 1.4k forks source link

Android: Key presses may cause doubled events #5259

Open pjanx opened 4 days ago

pjanx commented 4 days ago

Checklist

Describe the bug

With different virtual keyboards (Samsung Keyboard, Unexpected Keyboard, however Microsoft SwiftKey is fine) and also with an attached hardware keyboard, I get doubled key presses. The observation with a hardware keyboard is such that the app then acts on both pressing and releasing the keys.

I've never seen it with another app. I couldn't manage to reproduce it in an emulator.

How to reproduce

Switch around virtual keyboards, type into an Entry, and also use the Backspace key.

Screenshots

No response

Example code

package main

import (
    "net"

    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/dialog"
    "fyne.io/fyne/v2/driver/mobile"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    w := a.NewWindow("Bugs")
    w.Resize(fyne.NewSize(640, 480))
    w.SetContent(widget.NewMultiLineEntry())

    connectAddress := widget.NewEntry()
    connectAddress.SetPlaceHolder("host:port")
    connectAddress.Validator = func(text string) error {
        _, _, err := net.SplitHostPort(text)
        return err
    }
    connectAddress.SetText(string([]byte{3, 2, 1, 65, 66, 67, ':', '1'}))
    connectAddress.TypedKey(&fyne.KeyEvent{Name: fyne.KeyPageDown})

    var wConnect *dialog.FormDialog
    wConnect = dialog.NewForm("Connect to relay", "Connect", "Exit",
        []*widget.FormItem{
            {Text: "Address:", Widget: connectAddress},
        }, func(ok bool) {
            if ok {
            } else if _, ok := a.Driver().(mobile.Driver); ok {
                wConnect.Show()
            } else {
                a.Quit()
            }
        }, w)
    wConnect.Show()
    w.ShowAndRun()
}

Fyne version

2.5.2

Go compiler version

1.23.2

Operating system and version

Android 13 One UI 5.1

Additional Information

No response

andydotxyz commented 1 day ago

Which soft keyboard did you have loaded?

Is it all keys or just some? (I.e. characters / numbers / control could all behave differently)

pjanx commented 1 day ago

It's a bit wild: