1
0
mirror of https://github.com/ocornut/imgui.git synced 2025-01-30 11:37:29 +01:00

EndGroup(): Made IsItemHovered() work when an item was activated within the group (#849) (loosely follows #840)

This commit is contained in:
ocornut 2016-10-01 14:10:24 +02:00
parent 82dcdc9dfc
commit dfe4683c17

View File

@ -9196,8 +9196,11 @@ void ImGui::EndGroup()
// If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive() will function on the entire group. // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive() will function on the entire group.
// It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but if you search for LastItemId you'll notice it is only used in that context. // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but if you search for LastItemId you'll notice it is only used in that context.
if (!group_data.BackupActiveIdIsAlive && g.ActiveIdIsAlive && g.ActiveId && g.ActiveIdWindow->RootWindow == window->RootWindow) const bool active_id_within_group = (!group_data.BackupActiveIdIsAlive && g.ActiveIdIsAlive && g.ActiveId && g.ActiveIdWindow->RootWindow == window->RootWindow);
if (active_id_within_group)
window->DC.LastItemId = g.ActiveId; window->DC.LastItemId = g.ActiveId;
if (active_id_within_group && g.HoveredId == g.ActiveId)
window->DC.LastItemHoveredAndUsable = window->DC.LastItemHoveredRect = true;
window->DC.GroupStack.pop_back(); window->DC.GroupStack.pop_back();