Git Product home page Git Product logo

Comments (4)

mosra avatar mosra commented on May 23, 2024

Hi!

coincidentally, we were discussing this exact issue yesterday on the Gitter channel. The problem is that, for text input, SDL2 and GLFW fire both keyPressEvent() and textInputEvent() for each key that can be treated as text input. I was digging in SDL2 sources to find out a way if this behavior can be configured, but it just unconditionally fires both. Looking at GLFW docs, there's no way to override this either (didn't check the source tho) :/

If you scroll through the channel archives in the above link, an ImGui-specific workaround involves checking ImGui::GetIO().wantCaptureMouse and ImGui::GetIO().wantTextInput in addition to the return value from handleKeyPressEvent(), so maybe that could be a (temporary) solution for you as well?

A proper fix needs to be done on the Sdl2Application / GlfwApplication side, but so far I'm pretty clueless as how the fix should look, especially since the key press is fired before the text input, which is exactly the other way than what would be ~easily fixable. Googling around, I only found this thread but it quickly turned into a heated discussion involving OOP, with no useful information whatsoever.

from magnum-integration.

Getshi avatar Getshi commented on May 23, 2024

So

if (m_imgui.handleKeyPressEvent(event) || ImGui::GetIO().WantTextInput)
    return;

seems to be working fine, thanks for the quick suggestion! I've left out the ImGui::GetIO().WantCaptureMouse, since the even hovering a DragFloat would eat but the events.

Is there any reason this solution is just a temporary fix? Otherwise this could just be done automatically by handleKeyPressEvent.

from magnum-integration.

mosra avatar mosra commented on May 23, 2024

If I'm not mistaken, the above is doing the same as this:

if (m_imgui.handleKeyPressEvent(event) || isTextInputActive())
    return;

This in practice means, if any text input widget is active, it disallows handling of any key press events. For example, that would mean Ctrl S to trigger a file save would not be working if a text area is focused. Or F1 to open a help. Etc.

So while the above works for you (and for majority of other users as well), the proper fix is to suppress the key press event only if it really produces some text input. And that's a thing I currently don't know how to handle portably -- it needs to take into account dead keys (diacritics), Unicode, IME etc.

from magnum-integration.

Getshi avatar Getshi commented on May 23, 2024

Good to know, thanks for the explanation!

from magnum-integration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.