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

Possible focus bug in keypad navigation #1768

Closed
cmsj opened this issue Apr 23, 2018 · 2 comments
Closed

Possible focus bug in keypad navigation #1768

cmsj opened this issue Apr 23, 2018 · 2 comments
Labels
label/id and id stack implicit identifiers, pushid(), id stack

Comments

@cmsj
Copy link

cmsj commented Apr 23, 2018

Version/Branch of Dear ImGui:

master by way of the recent Vita port: https://github.com/Rinnegatamante/imgui-vita

Back-end/Renderer/OS: (if the question is related to inputs or rendering, otherwise delete this section)

Vita impl (uses vitaGL)

My Issue/Question: (please provide context)

I'm playing around with using imgui to make some Vita homebrew and I enabled the keypad navigation (which AIUI is beta atm) and I have two widgets that get the focus highlight at the same time:

https://github.com/cmsj/imgui-vita/blob/more-vita-suitable-example/example/main.cpp#L110

(the Combo and ListBox, specifically).

I'm super new to imgui though, so I'm fully prepared to believe this is my fault, or an issue with the vita port somehow!

Standalone, minimal, complete and verifiable example: (see CONTRIBUTING.md)

        ImGui::Begin("Example Bug");

        ImVec2 headerButtonSize = ImVec2(200.0f, 75.0f);
        ImGui::Columns(3, "tabbar", false);
        if (ImGui::Button("Browse", headerButtonSize)) current_window = BT_WIN_BROWSE;
        ImGui::NextColumn();
        if (ImGui::Button("Search", headerButtonSize)) current_window = BT_WIN_SEARCH;
        ImGui::NextColumn();
        if (ImGui::Button("Updates", headerButtonSize)) current_window = BT_WIN_UPDATE;
        ImGui::Columns(1);
        ImGui::Spacing();

        ImGui::Columns(2, "category", false);
        ImGui::SetColumnWidth(-1, 200.0f);
        ImGui::PushItemWidth(-1.0f);
        ImGui::Text("Category:");
        ImGui::PopItemWidth();
        ImGui::NextColumn();
        ImGui::PushItemWidth(-1.0f);
        ImGui::Combo("", &current_category, categories, IM_ARRAYSIZE(categories));
        ImGui::Columns(1);
        ImGui::Spacing();

        ImGui::PushItemWidth(-1.0f);
        ImGui::ListBox("", &selected_app, apps, IM_ARRAYSIZE(apps), 11);
        ImGui::End();

(categories and apps are both const char*[])

Taken from: https://github.com/cmsj/imgui-vita/blob/more-vita-suitable-example/example/main.cpp

Screenshots/Video (you can drag files here)

img_0493

@ocornut
Copy link
Owner

ocornut commented Apr 23, 2018

Hello,

ImGui::Combo("", &current_category, categories, IM_ARRAYSIZE(categories));
ImGui::ListBox("", &selected_app, apps, IM_ARRAYSIZE(apps), 11);

Your widgets have the same ID here.
Read the FAQ section How can I have multiple widgets with the same label or without a label? A primer on labels and the ID Stack. on how to work with the ID stack and ID system.

Basically this would work in your case:

ImGui::Combo("##categories", &current_category, categories, IM_ARRAYSIZE(categories));
[...]
ImGui::ListBox("##apps", &selected_app, apps, IM_ARRAYSIZE(apps), 11);

PS: To vertically align your "Category:" label with the text of the following combo box, you may call AlignTextToFramePadding() at the beginning of the line.

@cmsj
Copy link
Author

cmsj commented Apr 23, 2018

facepalm thank you very much for the reply, and for ImGui!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
label/id and id stack implicit identifiers, pushid(), id stack
Projects
None yet
Development

No branches or pull requests

2 participants