1
0
mirror of synced 2025-01-29 19:17:28 +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();
}
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
this->getWindowOpenState() = false;
}
}
};

View File

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

View File

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

View File

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

View File

@ -40,7 +40,7 @@ namespace hex::plugin::builtin {
}
ImGui::SameLine();
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->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();
}

View File

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

View File

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

View File

@ -106,7 +106,7 @@ namespace hex::plugin::builtin {
}
ImGui::SameLine();
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->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);
if (ImGui::Button("hex.builtin.common.close"_lang))
if (ImGui::Button("hex.builtin.common.close"_lang) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
Popup::close();
}
};

View File

@ -34,7 +34,7 @@ public:
}
ImGui::SameLine();
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;
this->close();
}
@ -87,7 +87,7 @@ public:
ImGui::EndDisabled();
ImGui::SameLine();
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 = "";
this->close();
}