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

How to immediately focus elements #7473

Open
katemonster33 opened this issue Apr 5, 2024 · 1 comment
Open

How to immediately focus elements #7473

katemonster33 opened this issue Apr 5, 2024 · 1 comment

Comments

@katemonster33
Copy link

katemonster33 commented Apr 5, 2024

Version/Branch of Dear ImGui:

Version 1.89.6, Branch: master

Back-ends:

imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer2.cpp

Compiler, OS:

Windows, Linux, android

Full config/build information:

No response

Details:

My Issue/Question:

Somewhat of a continuation of #7444 unfortunately, I have a screen that has Buttons, InputTexts, and a table with ScrollY enabled (so a child window). InputText is a single widget at the top of the window, not inside the table, just to be clear. Some users use only keyboard, and they expect that, when they hit the arrow keys, the Table is able to be scrolled, and when they enter alphanumeric characters, the InputText field accepts the characters immediately.

So I am working on setting the focus more dynamically than in the linked issue. I am trying to focus one element or the other based on what keyboard keys are being pressed. The problem is, from the users point of view, they'd like the input to be processed immediately. So, if they are scrolling the table with the mouse and press a key on the keyboard, they want the pressed key to show up in the InputText.

I started by using SetKeyboardFocusHere but the element didn't focus until the next frame, so the input was missed. What function can I use to ensure the widget is activated immediately so that input is processed into the widget?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

@katemonster33
Copy link
Author

well i am working on implementing a work-around since it seems like what I am trying to do can't be done without modifying ImGui. The work-around defining some keys to set the focus to the InputText field and then back to the Table. But I stumbled on a new thing - so this current version of ImGui we are on (1.89.6, I had it wrong originally in the issue title) has no way for the user to reliably modify the char* array sent to the InputText field without it being over-written?

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

No branches or pull requests

2 participants