1
0
mirror of synced 2025-02-06 14:14:22 +01:00

impr: Allow more popups to be closed with Escape

This commit is contained in:
WerWolv 2023-12-13 15:08:27 +01:00
parent 92043a3d23
commit 346f1362c6
10 changed files with 24 additions and 6 deletions

View File

@ -176,6 +176,9 @@ namespace hex {
ImGui::EndPopup(); ImGui::EndPopup();
} }
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
this->getWindowOpenState() = false;
} }
} }
}; };

View File

@ -68,6 +68,9 @@ namespace hex::plugin::builtin {
} }
} }
ImGui::EndChild(); ImGui::EndChild();
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
this->close();
} }
[[nodiscard]] ImGuiWindowFlags getFlags() const override { [[nodiscard]] ImGuiWindowFlags getFlags() const override {

View File

@ -87,6 +87,9 @@ namespace hex::plugin::builtin {
Popup::close(); Popup::close();
}, {}, this->m_multiple); }, {}, this->m_multiple);
} }
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
this->close();
} }
[[nodiscard]] ImGuiWindowFlags getFlags() const override { [[nodiscard]] ImGuiWindowFlags getFlags() const override {

View File

@ -27,6 +27,9 @@ namespace hex::plugin::builtin {
this->m_function(); this->m_function();
ImGui::SetWindowPos((ImHexApi::System::getMainWindowSize() - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing); ImGui::SetWindowPos((ImHexApi::System::getMainWindowSize() - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing);
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
this->close();
} }
[[nodiscard]] ImGuiWindowFlags getFlags() const override { [[nodiscard]] ImGuiWindowFlags getFlags() const override {

View File

@ -40,7 +40,7 @@ namespace hex::plugin::builtin {
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosX(width / 9 * 5); ImGui::SetCursorPosX(width / 9 * 5);
if (ImGui::Button("hex.builtin.common.no"_lang, ImVec2(width / 3, 0))) { if (ImGui::Button("hex.builtin.common.no"_lang, ImVec2(width / 3, 0)) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
this->m_noFunction(); this->m_noFunction();
this->close(); this->close();
} }

View File

@ -92,7 +92,7 @@ namespace hex::plugin::builtin {
} }
); );
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
this->close(); this->close();
} }

View File

@ -65,6 +65,9 @@ namespace hex::plugin::builtin::recent {
ImGui::EndTable(); ImGui::EndTable();
} }
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
this->close();
} }
[[nodiscard]] ImGuiWindowFlags getFlags() const override { [[nodiscard]] ImGuiWindowFlags getFlags() const override {

View File

@ -36,6 +36,9 @@ namespace hex::plugin::builtin {
ImGui::NewLine(); ImGui::NewLine();
ImGui::InputText("##result", this->m_result, ImGuiInputTextFlags_ReadOnly); ImGui::InputText("##result", this->m_result, ImGuiInputTextFlags_ReadOnly);
ImGui::PopItemWidth(); ImGui::PopItemWidth();
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
this->close();
} }
[[nodiscard]] ImGuiWindowFlags getFlags() const override { [[nodiscard]] ImGuiWindowFlags getFlags() const override {

View File

@ -106,7 +106,7 @@ namespace hex::plugin::builtin {
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosX(width / 9 * 5); ImGui::SetCursorPosX(width / 9 * 5);
if (ImGui::Button("hex.builtin.popup.safety_backup.delete"_lang, ImVec2(width / 3, 0))) { if (ImGui::Button("hex.builtin.popup.safety_backup.delete"_lang, ImVec2(width / 3, 0)) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
this->m_deleteCallback(); this->m_deleteCallback();
this->close(); this->close();
@ -131,7 +131,7 @@ namespace hex::plugin::builtin {
ImGui::SameLine((ImGui::GetMainViewport()->Size / 3 - ImGui::CalcTextSize("hex.builtin.common.close"_lang) - ImGui::GetStyle().FramePadding).x); ImGui::SameLine((ImGui::GetMainViewport()->Size / 3 - ImGui::CalcTextSize("hex.builtin.common.close"_lang) - ImGui::GetStyle().FramePadding).x);
if (ImGui::Button("hex.builtin.common.close"_lang)) if (ImGui::Button("hex.builtin.common.close"_lang) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
Popup::close(); Popup::close();
} }
}; };

View File

@ -34,7 +34,7 @@ public:
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosX(width / 9 * 5); ImGui::SetCursorPosX(width / 9 * 5);
if (ImGui::Button("hex.builtin.common.no"_lang, ImVec2(width / 3, 0))) { if (ImGui::Button("hex.builtin.common.no"_lang, ImVec2(width / 3, 0)) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
s_yesNoQuestionBoxResult = false; s_yesNoQuestionBoxResult = false;
this->close(); this->close();
} }
@ -87,7 +87,7 @@ public:
ImGui::EndDisabled(); ImGui::EndDisabled();
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPosX(width / 9 * 5); ImGui::SetCursorPosX(width / 9 * 5);
if (ImGui::Button("hex.builtin.common.cancel"_lang, ImVec2(width / 3, 0))) { if (ImGui::Button("hex.builtin.common.cancel"_lang, ImVec2(width / 3, 0)) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape))) {
s_inputTextBoxResult = ""; s_inputTextBoxResult = "";
this->close(); this->close();
} }