Skip to content

Commit

Permalink
Nav: Menu: Allow PadDown to open a menu from a menu bar, PadRight fro…
Browse files Browse the repository at this point in the history
…m a menu (#323, #126)
  • Loading branch information
ocornut committed Aug 4, 2016
1 parent dcff032 commit c263961
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9754,14 +9754,25 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
want_close = menu_is_open;
want_open = !menu_is_open;
}
if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiNavDir_Right) // Nav-Right to open
{
want_open = true;
g.NavMoveRequest = false;
}
}
else if (menu_is_open && pressed && menuset_is_open) // menu-bar: click open menu to close
else if (menu_is_open && pressed && menuset_is_open) // Menu bar: click an open menu again to close it
{
want_close = true;
want_open = menu_is_open = false;
}
else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // menu-bar: first click to open, then hover to open others
else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // Menu bar: click to open a first menu, then hover to open others
want_open = true;
else if (g.NavId == id && g.NavMoveRequest && g.NavMoveDir == ImGuiNavDir_Down) // Menu bar: Nav-Down to open
{
g.NavMoveRequest = false;
want_open = true;
}

if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
want_close = true;
if (want_close && IsPopupOpen(id))
Expand Down

0 comments on commit c263961

Please sign in to comment.