Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Error when run sample on web #171

Open
jeenhyung opened this issue May 4, 2016 · 2 comments
Open

Error when run sample on web #171

jeenhyung opened this issue May 4, 2016 · 2 comments

Comments

@jeenhyung
Copy link

jeenhyung commented May 4, 2016

[OSX 10.10.5]
when i run gxui sample project on web.
but, I get this error:

github.com/google/gxui/drivers/gl/keyboard_translate.go:141:7: duplicate case glfw.KeyEnd (constant -1 of type github.com/goxjs/glfw.Key) in expression switch
github.com/google/gxui/drivers/gl/keyboard_translate.go:113:7: previous case
github.com/google/gxui/drivers/gl/keyboard_translate.go:145:7: duplicate case glfw.KeyScrollLock (constant -1 of type github.com/goxjs/glfw.Key) in expression switch
github.com/google/gxui/drivers/gl/keyboard_translate.go:113:7: previous case
github.com/google/gxui/drivers/gl/keyboard_translate.go:147:7: duplicate case glfw.KeyNumLock (constant -1 of type github.com/goxjs/glfw.Key) in expression switch
github.com/google/gxui/drivers/gl/keyboard_translate.go:113:7: previous case
github.com/google/gxui/drivers/gl/keyboard_translate.go:149:7: duplicate case glfw.KeyPrintScreen (constant -1 of type github.com/goxjs/glfw.Key) in expression switch
github.com/google/gxui/drivers/gl/keyboard_translate.go:113:7: previous case
github.com/google/gxui/drivers/gl/keyboard_translate.go:151:7: duplicate case glfw.KeyPause (constant -1 of type github.com/goxjs/glfw.Key) in expression switch
github.com/google/gxui/drivers/gl/keyboard_translate.go:113:7: previous case
github.com/google/gxui/drivers/gl/keyboard_translate.go:113:7: too many errors

Help plz fix this.

@dmitshur
Copy link
Member

dmitshur commented May 4, 2016

This looks like a legitimate issue. I suspect it wasn't caught before because the GopherJS had a bug where it did not fail to compile when a switch had duplicate cases (see golang/go#11578 as the upstream issue).

That issue has since been fixed (i.e., gopherjs/gopherjs#269 is resolved), and this Go code is invalid and needs to be fixed for it to compile successfully.

The code to be fixed is here:

https://github.com/goxjs/glfw/blob/3ef83661bf02c111e9f84faada310a95c1762132/browser.go#L638

All those duplicate -1 key constants values are not compatible with the gxui code in keyboard_translate.go. They need to be changed to unique values.

The Web APIs should be consulted in order to give them values compatible with what KeyboardEvents set their keyCode property to. See the keyCode tables at https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode. I will accept a PR to https://github.com/goxjs/glfw that fixes this issue.

dmitshur added a commit to goxjs/glfw that referenced this issue May 5, 2016
They still need to be set to proper values, but this fixes issue where
downstream code may fail to compile if it expects each Key to have a
unique value (e.g., if they're used as switch case statements).

Fixes google/gxui#171.
@dmitshur
Copy link
Member

dmitshur commented May 5, 2016

@jeenhyung, I have fixed the issue in goxjs/glfw@aee868d. Please update github.com/goxjs/glfw to latest version and gxui will work in browser.

This issue can be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants