MultiSelect: Temporary fix/work-around for child/popup to not inherit MultiSelectEnabled flag, until we make mulit-select data stackable.
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index b4a7f09..d7f7aa7 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -2857,7 +2857,7 @@
if (ImGui::RadioButton("Tree nodes", widget_type == WidgetType_TreeNode)) { widget_type = WidgetType_TreeNode; }
ImGui::SameLine();
ImGui::Checkbox("Use 2 columns", &use_columns);
- ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int*)&ImGui::GetIO().ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
+ ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", &ImGui::GetIO().ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
ImGui::SameLine(); HelpMarker("Hold CTRL and click to select multiple items. Hold SHIFT to select a range. Keyboard is also supported.");
// Open a scrolling region
@@ -2918,6 +2918,14 @@
ImGui::TreePop();
}
+ // Right-click: context menu
+ if (ImGui::BeginPopupContextItem())
+ {
+ ImGui::Text("(Testing Selectable inside an embedded popup)");
+ ImGui::Selectable("Close");
+ ImGui::EndPopup();
+ }
+
if (use_columns)
{
ImGui::NextColumn();
diff --git a/imgui_internal.h b/imgui_internal.h
index 005df30..60a0280 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -2120,9 +2120,9 @@
ImVec2 NavWindowingAccumDeltaSize;
// Range-Select/Multi-Select
- bool MultiSelectEnabled;
+ ImGuiWindow* MultiSelectEnabledWindow; // FIXME-MULTISELECT: We currently don't support recursing/stacking multi-select
ImGuiMultiSelectFlags MultiSelectFlags;
- ImGuiMultiSelectState MultiSelectState; // We currently don't support recursing/stacking multi-select
+ ImGuiMultiSelectState MultiSelectState;
ImGuiKeyChord MultiSelectKeyMods;
// Render
@@ -2388,7 +2388,7 @@
NavWindowingToggleLayer = false;
NavWindowingToggleKey = ImGuiKey_None;
- MultiSelectEnabled = false;
+ MultiSelectEnabledWindow = NULL;
MultiSelectFlags = ImGuiMultiSelectFlags_None;
MultiSelectKeyMods = ImGuiMod_None;
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index 5c344c7..528a918 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -6464,7 +6464,7 @@
const bool was_selected = selected;
// Multi-selection support (header)
- const bool is_multi_select = g.MultiSelectEnabled;
+ const bool is_multi_select = (g.MultiSelectEnabledWindow == window);
if (is_multi_select)
{
MultiSelectItemHeader(id, &selected);
@@ -6816,7 +6816,7 @@
if ((flags & ImGuiSelectableFlags_AllowOverlap) || (g.LastItemData.InFlags & ImGuiItemFlags_AllowOverlap)) { button_flags |= ImGuiButtonFlags_AllowOverlap; }
// Multi-selection support (header)
- const bool is_multi_select = g.MultiSelectEnabled;
+ const bool is_multi_select = (g.MultiSelectEnabledWindow == window);
const bool was_selected = selected;
if (is_multi_select)
{
@@ -7126,7 +7126,7 @@
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
- IM_ASSERT(g.MultiSelectEnabled == false); // No recursion allowed yet (we could allow it if we deem it useful)
+ IM_ASSERT(g.MultiSelectEnabledWindow == NULL); // No recursion allowed yet (we could allow it if we deem it useful)
IM_ASSERT(g.MultiSelectFlags == 0);
IM_ASSERT(g.MultiSelectState.FocusScopeId == 0);
@@ -7135,7 +7135,7 @@
ms->Clear();
ms->FocusScopeId = window->IDStack.back();
PushFocusScope(ms->FocusScopeId);
- g.MultiSelectEnabled = true;
+ g.MultiSelectEnabledWindow = window;
g.MultiSelectFlags = flags;
// Use copy of keyboard mods at the time of the request, otherwise we would requires mods to be held for an extra frame.
@@ -7182,7 +7182,7 @@
ms->Out.RangeValue = true;
g.MultiSelectState.FocusScopeId = 0;
PopFocusScope();
- g.MultiSelectEnabled = false;
+ g.MultiSelectEnabledWindow = NULL;
g.MultiSelectFlags = ImGuiMultiSelectFlags_None;
#ifdef IMGUI_DEBUG_MULTISELECT