Skip to content

Commit 63bfad4

Browse files
committed
MultiSelect: added ImGuiMultiSelectFlags_NoSelectOnRightClick. (#8200, #9015)
1 parent e11b7a0 commit 63bfad4

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

docs/CHANGELOG.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ Other Changes:
5353
resizing the parent window while keeping the multi-line field active (which is
5454
most typically achieved when resizing programmatically or via a docking layout
5555
reacting to a platform window resize). (#3237, #9007) [@anton-kl, @ocornut]
56+
- MultiSelect: added ImGuiMultiSelectFlags_NoSelectOnRightClick to disable default
57+
right-click processing, which selects item on mouse down and is designed for
58+
context-menus. (#8200, #9015)
5659
- Backends: Vulkan: added IMGUI_IMPL_VULKAN_VOLK_FILENAME to configure path to
5760
Volk (default to "volk.h"). (#9008, #7722, #6582, #4854) [@mwlasiuk]
5861
- Backends: WebGPU: update to compile with Dawn and Emscripten's 4.0.10+

imgui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,7 @@ enum ImGuiMultiSelectFlags_
30033003
ImGuiMultiSelectFlags_SelectOnClickRelease = 1 << 14, // Apply selection on mouse release when clicking an unselected item. Allow dragging an unselected item without altering selection.
30043004
//ImGuiMultiSelectFlags_RangeSelect2d = 1 << 15, // Shift+Selection uses 2d geometry instead of linear sequence, so possible to use Shift+up/down to select vertically in grid. Analogous to what BoxSelect does.
30053005
ImGuiMultiSelectFlags_NavWrapX = 1 << 16, // [Temporary] Enable navigation wrapping on X axis. Provided as a convenience because we don't have a design for the general Nav API for this yet. When the more general feature be public we may obsolete this flag in favor of new one.
3006+
ImGuiMultiSelectFlags_NoSelectOnRightClick = 1 << 17, // Disable default right-click processing, which selects item on mouse down, and is designed for context-menus.
30063007
};
30073008

30083009
// Main IO structure returned by BeginMultiSelect()/EndMultiSelect().

imgui_demo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,6 +2647,10 @@ static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_d
26472647
{
26482648
HelpMarker("Selections can be built using Selectable(), TreeNode() or other widgets. Selection state is owned by application code/data.");
26492649

2650+
ImGui::BulletText("Wiki page:");
2651+
ImGui::SameLine();
2652+
ImGui::TextLinkOpenURL("imgui/wiki/Multi-Select", "https://github.com/ocornut/imgui/wiki/Multi-Select");
2653+
26502654
// Without any fancy API: manage single-selection yourself.
26512655
IMGUI_DEMO_MARKER("Widgets/Selection State/Single-Select");
26522656
if (ImGui::TreeNode("Single-Select"))
@@ -3180,6 +3184,7 @@ static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_d
31803184
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoSelect", &flags, ImGuiMultiSelectFlags_NoAutoSelect);
31813185
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClear", &flags, ImGuiMultiSelectFlags_NoAutoClear);
31823186
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoAutoClearOnReselect", &flags, ImGuiMultiSelectFlags_NoAutoClearOnReselect);
3187+
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_NoSelectOnRightClick", &flags, ImGuiMultiSelectFlags_NoSelectOnRightClick);
31833188
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect1d", &flags, ImGuiMultiSelectFlags_BoxSelect1d);
31843189
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelect2d", &flags, ImGuiMultiSelectFlags_BoxSelect2d);
31853190
ImGui::CheckboxFlags("ImGuiMultiSelectFlags_BoxSelectNoScroll", &flags, ImGuiMultiSelectFlags_BoxSelectNoScroll);

imgui_widgets.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8213,8 +8213,8 @@ void ImGui::MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed)
82138213
}
82148214

82158215
// Right-click handling.
8216-
// FIXME-MULTISELECT: Currently filtered out by ImGuiMultiSelectFlags_NoAutoSelect but maybe should be moved to Selectable(). See https://github.com/ocornut/imgui/pull/5816
8217-
if (hovered && IsMouseClicked(1) && (flags & ImGuiMultiSelectFlags_NoAutoSelect) == 0)
8216+
// FIXME-MULTISELECT: Maybe should be moved to Selectable()? Also see #5816, #8200, #9015
8217+
if (hovered && IsMouseClicked(1) && (flags & (ImGuiMultiSelectFlags_NoAutoSelect | ImGuiMultiSelectFlags_NoSelectOnRightClick)) == 0)
82188218
{
82198219
if (g.ActiveId != 0 && g.ActiveId != id)
82208220
ClearActiveID();

0 commit comments

Comments
 (0)