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

List Box - elements with the same name #6223

Closed
KrzysztofKieszkowski opened this issue Mar 4, 2023 · 1 comment
Closed

List Box - elements with the same name #6223

KrzysztofKieszkowski opened this issue Mar 4, 2023 · 1 comment
Labels
label/id and id stack implicit identifiers, pushid(), id stack

Comments

@KrzysztofKieszkowski
Copy link

lets try this list box and select element
it doen't work:(

const char* items[] = { "AAAA", "AAAA", "AAAA", "DDDD", "DDDD", "FFFF", "GGGG", "DDDD", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "DDDD" };
static int item_current_idx = 0; // Here we store our selection data as an index.
if (ImGui::BeginListBox("listbox 1"))
{
for (int n = 0; n < IM_ARRAYSIZE(items); n++)
{
const bool is_selected = (item_current_idx == n);
if (ImGui::Selectable(items[n], is_selected))
item_current_idx = n;

            // Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
            if (is_selected)
                ImGui::SetItemDefaultFocus();
        }
        ImGui::EndListBox();
    }
@ocornut
Copy link
Owner

ocornut commented Mar 4, 2023

This is answered in the FAQ.

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