-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Closed
Labels
Description
Consider the following example code:
static int val = 0;
ImGui::Begin("test");
ImGui::Text("%i", val);
// Option 1
if(ImGui::BeginMenu("selectable"))
{
ImGui::Text("context");
ImGui::EndMenu();
if(ImGui::IsItemClicked()) val = 1;
}
// Option 2
if(ImGui::BeginMenu("outer"))
{
if(ImGui::BeginMenu("selectable"))
{
ImGui::Text("context");
ImGui::EndMenu();
if(ImGui::IsItemClicked()) val = 2;
}
ImGui::EndMenu();
}
ImGui::End();
Here I am displaying some text value, selectable
, which I want to be able to select. This entry has some additional context to be displayed when it's hovered over. I also want this context to be to the side of the displayed value, and with an indicator that there is something more to display. BeginMenu()
seems to be fitting to these requirements. However, when the code is used, as presented in option 1, the IsItemClicked()
call never returns true, and val
is never set to 1.
If the same code would be wrapped into an encompassing BeginMenu()
call, like in option 2, then IsItemClicked()
is working as expected, and val
can be set to 2.
What would be the correct course of action to take here?