cabana: preserve selected menu color on hover (#38909)

* cabana: unify menu highlight colors

* cabana: preserve selected menu color on hover
This commit is contained in:
Trey Moen
2026-09-13 16:54:34 -07:00
committed by GitHub
parent d3106c2b4b
commit 64e5d1e5e3
+6 -1
View File
@@ -86,7 +86,12 @@ inline void EndPopup() {
inline bool BeginMenu(const char *label, bool enabled = true) {
PopupViewportScope viewport_scope;
pushStyle();
return finishBegin(ImGui::BeginMenu(label, enabled));
// An open menu keeps its selection color while the pointer is over its label.
const bool selected = ImGui::IsPopupOpen(label);
if (selected) ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImGui::GetStyleColorVec4(ImGuiCol_Header));
const bool open = ImGui::BeginMenu(label, enabled);
if (selected) ImGui::PopStyleColor();
return finishBegin(open);
}
inline void EndMenu() {
ImGui::PopStyleVar();