ButtonBehavior: Tidying up.

This commit is contained in:
omar 2017-09-28 19:47:45 +02:00
parent 4b4e455c40
commit dd0855de5c

View File

@ -6589,7 +6589,9 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
} }
bool held = false; bool held = false;
if (g.ActiveId == id && g.ActiveIdSource == ImGuiInputSource_Mouse) if (g.ActiveId == id)
{
if (g.ActiveIdSource == ImGuiInputSource_Mouse)
{ {
if (g.IO.MouseDown[0]) if (g.IO.MouseDown[0])
{ {
@ -6605,9 +6607,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
if (!(flags & ImGuiButtonFlags_NoNavOverride)) if (!(flags & ImGuiButtonFlags_NoNavOverride))
g.NavDisableHighlight = true; g.NavDisableHighlight = true;
} }
if (g.ActiveId == id && g.ActiveIdSource == ImGuiInputSource_Nav) else if (g.ActiveIdSource == ImGuiInputSource_Nav)
{
if (!IsNavInputDown(ImGuiNavInput_PadActivate)) if (!IsNavInputDown(ImGuiNavInput_PadActivate))
ClearActiveID(); ClearActiveID();
}
}
// AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one. // AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one.
if (hovered && (flags & ImGuiButtonFlags_AllowOverlapMode) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0)) if (hovered && (flags & ImGuiButtonFlags_AllowOverlapMode) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0))