From 55d791f852f0416852195a9f050687019a46a892 Mon Sep 17 00:00:00 2001 From: YohananDiamond Date: Sat, 1 Jul 2023 15:15:41 -0300 Subject: [PATCH] command palette: improve checks on item selection --- src/gui/commandPalette.cpp | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/gui/commandPalette.cpp b/src/gui/commandPalette.cpp index 7bd29def1..532dc48a3 100644 --- a/src/gui/commandPalette.cpp +++ b/src/gui/commandPalette.cpp @@ -121,10 +121,7 @@ void FurnaceGUI::drawPalette() { if (curPaletteChoice>=(int)paletteSearchResults.size()) { curPaletteChoice=paletteSearchResults.size()-1; } - if (ImGui::IsKeyPressed(ImGuiKey_Enter)) { - // TODO: properly test this - what happens when enter is pressed and the list is empty? - accepted=true; - } + accepted=ImGui::IsKeyPressed(ImGuiKey_Enter); } if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) { @@ -132,28 +129,31 @@ void FurnaceGUI::drawPalette() { } if (accepted) { - int i=paletteSearchResults[curPaletteChoice]; - - switch (curPaletteType) { - case CMDPAL_TYPE_MAIN: - resetPalette(this); - doAction(i); - if (i