RangeSelect/MultiSelect: Added IMGUI_HAS_MULTI_SELECT define. Fixed right-click toggling selection without clearing active id, could lead to MarkItemEdited() asserting. Fixed demo.

This commit is contained in:
omar 2019-04-15 19:13:36 +02:00 committed by ocornut
parent 9b925d51bb
commit 0d73bf3755
2 changed files with 4 additions and 1 deletions

View File

@ -2368,6 +2368,7 @@ struct ImGuiListClipper
// 5) Call EndMultiSelect(). Save the value of ->RangeSrc for the next frame (you may convert the value in a format that is safe for persistance)
// 6) Honor Clear/SelectAll/SetRange requests by updating your selection data. Always process them in this order (as you will receive Clear+SetRange request simultaneously)
// If you submit all items (no clipper), Step 2 and 3 and will be handled by Selectable() on a per-item basis.
#define IMGUI_HAS_MULTI_SELECT // Multi-Select/Range-Select WIP branch // <-- This is currently _not_ in the top of imgui.h to prevent merge conflicts.
struct ImGuiMultiSelectData
{
bool RequestClear; // Begin, End // Request user to clear selection

View File

@ -6504,7 +6504,9 @@ void ImGui::MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed)
bool hovered = IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup);
if (hovered && IsMouseClicked(1))
{
SetFocusID(g.LastItemData.ID, window);
if (g.ActiveId != 0 && g.ActiveId != id)
ClearActiveID();
SetFocusID(id, window);
if (!pressed && !selected)
{
pressed = true;