Fixed a problem with dropdowns where, if you clicked a button inside them, they wouldn't register that they are no longer open.

This commit is contained in:
PS 2021-04-08 14:53:41 -10:00
parent cd2cfac16e
commit 232180299f
1 changed files with 9 additions and 2 deletions

View File

@ -1386,13 +1386,20 @@ ui_BeginDropdown(ui_interface* Interface, gs_string Text)
internal void
ui_EndDropdown(ui_interface* Interface)
{
gs_string LayoutName = MakeString("DropdownLayout");
ui_widget* Layout = Interface->ActiveLayout;
ui_widget_retained_state* State = ui_GetRetainedState(Interface, Layout->WidgetReference);
if (State)
{
if (State->Value)
bool IsOpen = State->Value;
ui_widget* Widget = Interface->ActiveLayout;
bool IsStillHot = StringsEqualUpToLength(Widget->String, LayoutName, LayoutName.Length);
if (IsOpen && IsStillHot)
{
ui_PopLayout(Interface, MakeString("DropdownLayout"));
ui_PopLayout(Interface, LayoutName);
} else if (IsOpen && !IsStillHot)
{
State->Value = false;
}
}
}