From f2bfb05a4488d27d7bb1781b2472972bbb1d8144 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 8 Jun 2025 16:44:24 -0500 Subject: [PATCH] [nostalgia/gfx/studio/palette] Make RGB key shortcuts work when color channel inputs are focused --- .../paletteeditor/paletteeditor-imgui.cpp | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/nostalgia/modules/gfx/src/studio/paletteeditor/paletteeditor-imgui.cpp b/src/nostalgia/modules/gfx/src/studio/paletteeditor/paletteeditor-imgui.cpp index af8d051e..cd61124f 100644 --- a/src/nostalgia/modules/gfx/src/studio/paletteeditor/paletteeditor-imgui.cpp +++ b/src/nostalgia/modules/gfx/src/studio/paletteeditor/paletteeditor-imgui.cpp @@ -302,11 +302,12 @@ void PaletteEditorImGui::drawColorEditor() noexcept { int const a = alpha16(c); auto const newName = ig::InputText<50>( "Name", m_pal.colorNames[m_selectedColorRow]); - bool inputFocused = ImGui::IsItemFocused(); + auto nameInputFocused = ImGui::IsItemFocused(); ImGui::Separator(); - colorInput("Red", r, inputFocused, FocusCmd::Red); - colorInput("Green", g, inputFocused, FocusCmd::Green); - colorInput("Blue", b, inputFocused, FocusCmd::Blue); + bool colorInFocused{}; + colorInput("Red", r, colorInFocused, FocusCmd::Red); + colorInput("Green", g, colorInFocused, FocusCmd::Green); + colorInput("Blue", b, colorInFocused, FocusCmd::Blue); // color preview { ImGui::PushStyleColor( @@ -320,20 +321,24 @@ void PaletteEditorImGui::drawColorEditor() noexcept { std::ignore = pushCommand( m_pal, m_page, m_selectedColorRow); } - if (ig::mainWinHasFocus() && !inputFocused && !ImGui::IsKeyDown(ImGuiKey_ModCtrl)) { + if (ig::mainWinHasFocus() && !ImGui::IsKeyDown(ImGuiKey_ModCtrl)) { if (!ImGui::IsKeyDown(ImGuiKey_ModAlt)) { - numShortcuts(m_selectedColorRow, largestPage(m_pal)); + if (!nameInputFocused && !colorInFocused) { + numShortcuts(m_selectedColorRow, largestPage(m_pal)); + } } else { numShortcuts(m_page, m_pal.pages.size()); } - if (ImGui::IsKeyDown(ImGuiKey_R)) { - m_focusCmd = FocusCmd::Red; - } - if (ImGui::IsKeyDown(ImGuiKey_G)) { - m_focusCmd = FocusCmd::Green; - } - if (ImGui::IsKeyDown(ImGuiKey_B)) { - m_focusCmd = FocusCmd::Blue; + if (!nameInputFocused) { + if (ImGui::IsKeyDown(ImGuiKey_R)) { + m_focusCmd = FocusCmd::Red; + } + if (ImGui::IsKeyDown(ImGuiKey_G)) { + m_focusCmd = FocusCmd::Green; + } + if (ImGui::IsKeyDown(ImGuiKey_B)) { + m_focusCmd = FocusCmd::Blue; + } } } auto const newColor = color16(r, g, b, a);