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

[bug] No meta keys work in UI elements #754

Closed
xxxserxxx opened this issue Jan 25, 2024 · 7 comments
Closed

[bug] No meta keys work in UI elements #754

xxxserxxx opened this issue Jan 25, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@xxxserxxx
Copy link

What happend?

While trying to hook into Enter key events in an InputText, I discovered that -- on my machine, at least -- no control/meta keys are being captured by giu CR, Del, Backspace, arrow keys -- none of them trigger any key capture events. With CallbackAlways, even mouse events trigger the callback, but none of the meta keys do. Output from xev looks ok, so I'm stuck about what's unique about my set-up.

The attached movie shows the behavior; I'm using screenkeys to show the keypresses.

Go: 1.21.6
giu: 0.7.0 (from go.mod)
OS/Platform:

giu.mp4

Code example

While I found this with different code, I also saw it in the giu examples/widgets program, as observed in the attached video.

To Reproduce

Since I'm seeing it in the giu code, it's likely that this is an environmental issue -- related to something particular to my set-up. I'm happy to help track it down.

Version

master

OS

Arch Linux kernel 6.7.1, Xorg 21.1.11

@xxxserxxx xxxserxxx added the bug Something isn't working label Jan 25, 2024
@gucio321
Copy link
Collaborator

well what? 😄 its really strange imao.
OMG But it happens to me too... let me debug this.

@gucio321
Copy link
Collaborator

gucio321 commented Feb 1, 2024

For now I can say that cimghui-go doesn't have this problem

@gucio321
Copy link
Collaborator

gucio321 commented Feb 1, 2024

ok, problem is about InputHandler, when I comment out MasterWindow.go:109 everything works

@gucio321
Copy link
Collaborator

Reason

in imgui_impl_glfw.cpp:

    glfwSetKeyCallback(vd->Window, ImGui_ImplGlfw_KeyCallback);

in glfw_backend.cpp:

void igGLFWWindow_SetKeyCallback(GLFWwindow *wnd) { glfwSetKeyCallback(wnd, (GLFWkeyfun)keyCallback); }

which is wrapped in glfw_backend.go:

func (b *GLFWBackend) SetKeyCallback(cbfun KeyCallback) {
        b.keyCb = cbfun
        C.igGLFWWindow_SetKeyCallback(b.handle())
}

and in giu we do (in MasterWindow.go):

        w.backend.SetKeyCallback(func(key, scanCode, action, modifier int) {
                fmt.Println(key, scanCode, action, modifier)
                k, m, a := keyFromGLFWKey(imgui.GLFWKey(key)), Modifier(modifier), Action(action)
                handler.Handle(k, m, a)
                if w.additionalInputCallback != nil {
                        w.additionalInputCallback(k, m, a)
                }
        })

conclusion:
we overwrite imgui's internal stuff. This issue should escalate to cimgui-go

@gucio321
Copy link
Collaborator

gucio321 commented Mar 1, 2024

I think our moves should be:

  • remove this SetKeyCallback from cimgui-go - ImGui supposes we don't use it at all.
  • re-implement InputHandler here in giu so that it uses ImGui API.

gucio321 added a commit to gucio321/giu that referenced this issue Mar 5, 2024
fix AllenDang#754

At this time I have no good idea for fix on this, but because this
causes that giu is useless, I've decided to disable very specific part of the framework that is not essential
gucio321 added a commit to gucio321/giu that referenced this issue Mar 5, 2024
fix AllenDang#754

At this time I have no good idea for fix on this, but because this
causes that giu is useless, I've decided to disable very specific part of the framework that is not essential
@gucio321
Copy link
Collaborator

well, I have a problem, because it works now, but I have no Idea why...
let me close this for now and I'll comment when I find what fixed that.

@gucio321
Copy link
Collaborator

hehe, git blame said this: #628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants