-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
How to stop text from being received by an inputtext when it's not being shown? #418
Comments
Or any insight into a better fundamental approach to this would be good. |
Well first you'd want to figure out if you are catching the text input when being shown or being hidden (you can do so by mapping show and hide on to two different keys).
I'm not sure how that would fail. |
I always have to call the imgui event handler in case there are other On Sun, Nov 29, 2015 at 1:49 AM, omar notifications@github.com wrote:
|
I don't understand. Could you provide some repro code based on the samples? |
OK I have created a repro (key value for GLFW here).
I am not sure it constitute a bug per-se. Text inputs receive the text inputs that are available and if your program looks anything like mine above there's no input capturing. The InputText() receive your input at the time is appears. Perhaps when you read the tilde key you can do a The subtle underlying bug that makes this NOT happen the first time is because the effect of SetKeyboardFocusHere() is deferred by one frame(as discussed in #432 and I aim to fix that). By the way instead of caling SetKeyboardFocusHere() every frame I recommend that you do something like:
or
Depending on what you want. |
I'll close this as there are variety of ways around (and yours is ok now). but let me know if there is something you're not sure about. It's a bit annoying that so many API aren't passing keypresses and text input in the same message (holding both values) it would allow easier filtering of that sort. Having effectively two streams of data (key presses and character) when you can't fully process them right away create this situation. I'm not sure how to do better at this point but it'll be an interesting edge case to consider if we refactor the input system. |
I've written a text console overlay that gets hidden/shown when the tilde key is pressed. The code for making the window is wrapped in an if block and the value of that boolean is changed when the user presses the tilde key (SDL_KEYDOWN on SDLK_BACKQUOTE).
However, either when it's being shown or being hidden (I'm not sure, but I press tilde twice and I only get one in the inputtext), the SDL_TEXTINPUT event goes through and the ` is added to the inputtext.
In my code for drawing the window, I have ImGui::SetKeyboardFocusHere(); called right before the inputtext so it doesn't lose focus when enter is called (I have return true on enter flag set) so I can reset the text to blank and have the user continue typing after enter is pressed.
How do I stop the ` from getting through to the inputtext?
Thank you so much! ImGui has saved me so much time and allowed me to add features I would have never even bothered with because they would have taken so much time. Especially love the up/down history and tab completion.
The text was updated successfully, but these errors were encountered: