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

ImGui::Text and responding to Key inputs #550

Closed
zmertens opened this issue Mar 11, 2016 · 3 comments
Closed

ImGui::Text and responding to Key inputs #550

zmertens opened this issue Mar 11, 2016 · 3 comments

Comments

@zmertens
Copy link

I am using the Stencil Overlays in ImGui with Imgui Text fields on them to build a Gui for my game. I want to be able to iterate over the text on them by responding to up / down inputs from the user. I know how to do this using enums and then indexing the list of text fields that I've created. But my question is whether or not ImGui can provide a mechanism to keep track of what text might be selected?

For instance, in the SDL2+OpenGL3 example this is a "Process Input (SDL_Event* ev)" function, and the keys are saved into an ImGuiIO field here:

case SDL_KEYDOWN:
case SDL_KEYUP:
{
   int key = event->key.keysym.sym & ~SDLK_SCANCODE_MASK;
        io.KeysDown[key] = (event->type == SDL_KEYDOWN);
        io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
        io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
        io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);

        SDL_Log("HELOASDOASDO\n");

        return true;
}

Additionally, in the Demo window example (in imgui_demo.cpp), there is a ImGui::TreeNode("Tabbing") example which shows that you can tab through the ImGui::InputText fields. I'm basically looking to use that functionality but with a different key (up / down) instead of tabbing and I don't want my fields editable (by the user).

@ocornut
Copy link
Owner

ocornut commented Mar 21, 2016

Hello.
This looks like a duplicate of #323 so I will close this. Unfortunately I don't have much avaliable resources to put into ImGui lately and this is a rather large feature. Daniel suggested here #456 (comment) to add a specialize version for menu/menu items first which might happen. Either way I don't have an ETA.

I don't want my fields editable

There is a ReadOnly flag in the InputTextFlags_ set.

@ocornut ocornut closed this as completed Mar 21, 2016
@ocornut
Copy link
Owner

ocornut commented Mar 21, 2016

FYI I am assuming it is a duplicate of #323 based on the last paragraph, but I can't really understand anything about your first paragraph. So you might want to clarify in more concrete details.

Your subject line says ImGui::Text() but there aren't selectable items. What would be the point in selecting them?

Your subject line says ImGui::Text() but there aren't selectable items. What would be the point in selecting them?

@zmertens
Copy link
Author

Your subject line says ImGui::Text() but there aren't selectable items. What would be the point in selecting them?
I meant highlightable. So what I was going for was registering which text is "selected" and then highlighting it. And by highlighting it I mean changing the color of the text.

Ah thanks for pointing me to those existing issues.

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

No branches or pull requests

2 participants