Comments (4)
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.
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.
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.
Good to know, thanks for the explanation!
from magnum-integration.
Related Issues (20)
- Add Support for Dear ImGui extensions HOT 1
- i get an error when i am trying running a robotic simulation with robot_dart and magnum HOT 1
- Crash in magnum-imgui Example Program HOT 1
- Consider switching from the legacy Find*.cmake modules to install(TARGETS ... EXPORT ...) HOT 10
- Could NOT find MagnumIntegration (missing: Dart) HOT 1
- [arch] build fails - lwop_ivec3 not defined HOT 2
- Magnum::ImGuiIntegration missing from debian package HOT 5
- How to use ImGui integration as subdirectory HOT 6
- Custom flags for Dear ImGui integration HOT 4
- Fail to build target iOS HOT 5
- ArchLinux PKGBUILD needs fixes HOT 1
- Linking failure with ImGui HEAD HOT 2
- ImGui integration does not support drawing lots of elements (ImGuiBackendFlags_RendererHasVtxOffset) HOT 7
- ImGui integration does not support adding UserCallback to DrawList HOT 1
- ImGui IdxOffset not honored correctly during frame drawing HOT 4
- Key Events have changed in ImGui HOT 10
- ImGUI IO assertion failure HOT 3
- Imgui_internal.h IMGUI_API inclusion HOT 16
- MSYS .gitattributes typo: Wrong line ending normalization under Windows HOT 2
- ImGuiIO modifier key states incorrect under Linux/X11 (glfw) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magnum-integration.