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

mobile/app/shiny.go: Mouse events not being delivered to application #20593

Open
donomii opened this issue Jun 6, 2017 · 1 comment
Open
Labels
mobile Android, iOS, and x/mobile
Milestone

Comments

@donomii
Copy link

donomii commented Jun 6, 2017

Please answer these questions before submitting your issue. Thanks!

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

go1.8.3 windows/amd64

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\user\Dropbox\goProjects;C:\Users\user\Dropbox\golibs
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\user\AppData\Local\Temp\go-build310428203=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

What did you do?

Attempted to write graphics program using mobile/app. Noticed no mouse events were delivered to application, due to code in mobile/app/shiny.go (convertEvent) that creates touch events based on mouse events, and then DISCARDS the mouse events.

No mouse events will ever reach the user code, meaning that events like WheelUp and WheelDown are completely unavailable to the application (all the application gets is a generic "touchstart" and "touchend", all the buttons are grouped together)

What did you expect to see?

Mouse events

What did you see instead?

No mouse events, at all

Fixed code

In order to cause minimum disruption to existing code, this following patch passes mouse events to the user, while also keeping the current behaviour of creating touch events. Note that only one line is changed, the rest of the function is just context.

mobile/app/shiny.go

func convertEvent(e interface{}) interface{} {
	switch e := e.(type) {
	case lifecycle.Event:
		if theApp.glctx == nil {
			theApp.glctx = e.DrawContext.(gl.Context)
		}
	case mouse.Event:
		te := touch.Event{
			X: e.X,
			Y: e.Y,
		}
		switch e.Direction {
		case mouse.DirNone:
			te.Type = touch.TypeMove
		case mouse.DirPress:
			te.Type = touch.TypeBegin
		case mouse.DirRelease:
			te.Type = touch.TypeEnd
		}
		theApp.Send(te)
	}
	return e
}

@donomii donomii changed the title Fix for broken mouse support in shiny.go mobile/app/shiny.go: Fix for broken mouse events Jun 6, 2017
@donomii donomii changed the title mobile/app/shiny.go: Fix for broken mouse events mobile/app/shiny.go: Fix broken mouse events Jun 6, 2017
@donomii donomii changed the title mobile/app/shiny.go: Fix broken mouse events mobile/app/shiny.go: Fix mouse events Jun 6, 2017
@donomii donomii changed the title mobile/app/shiny.go: Fix mouse events mobile/app/shiny.go: Mouse events not being delivered to application Jun 7, 2017
@bradfitz bradfitz added the mobile Android, iOS, and x/mobile label Jul 20, 2017
@ianlancetaylor
Copy link
Contributor

CC @eliasnaur @hyangah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

3 participants