Skip to content

x/exp/shiny: key repeats reported as release + press #18566

@barnex

Description

@barnex

What did you do?

This program opens an x/exp/shiny window and reports key presses:

package main

import (
    "log"
    "golang.org/x/exp/shiny/driver"
    "golang.org/x/exp/shiny/screen"
    "golang.org/x/mobile/event/key"
)

func main() {
    log.SetFlags(log.Lmicroseconds)
    driver.Main(func(s screen.Screen) {
        w, _ := s.NewWindow(nil)
        for {
            e := w.NextEvent()
            if e, ok := e.(key.Event); ok {
                log.Println(e.Direction)
            }
        }
    })
}

What did you expect to see?

According to https://github.com/golang/mobile/blob/master/event/key/key.go#L50, key repeats should report key.DirNone. So when pressing and holding down a key for a while, I expect to see:

11:59:49.544507 Press
11:59:50.045002 None
11:59:50.076717 None
11:59:50.107537 None
11:59:50.137585 Release

What did you see instead?

Holding down a key results in repeated Release/Press events:

11:59:49.544507 Press
11:59:50.045002 Release
11:59:50.045110 Press
11:59:50.076717 Release
11:59:50.076807 Press
11:59:50.107537 Release
11:59:50.107578 Press
11:59:50.137585 Release

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

go version go1.7.1 linux/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/arne"
GORACE=""
GOROOT="/home/arne/bin/go"
GOTOOLDIR="/home/arne/bin/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build871086202=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions