1
0
mirror of synced 2024-12-01 02:37:18 +01:00

impr: Make sure shortcuts can't be used when popups are open

This commit is contained in:
WerWolv 2023-03-31 11:07:53 +02:00
parent 173ed5475c
commit 722f6315c4

View File

@ -539,6 +539,8 @@ namespace hex {
void Window::frame() { void Window::frame() {
auto &io = ImGui::GetIO(); auto &io = ImGui::GetIO();
const bool popupOpen = ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId);
// Loop through all views and draw them // Loop through all views and draw them
for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) { for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
ImGui::GetCurrentContext()->NextWindowData.ClearFlags(); ImGui::GetCurrentContext()->NextWindowData.ClearFlags();
@ -557,7 +559,7 @@ namespace hex {
} }
// Handle per-view shortcuts // Handle per-view shortcuts
if (view->getWindowOpenState()) { if (view->getWindowOpenState() && !popupOpen) {
auto window = ImGui::FindWindowByName(view->getName().c_str()); auto window = ImGui::FindWindowByName(view->getName().c_str());
bool hasWindow = window != nullptr; bool hasWindow = window != nullptr;
bool focused = false; bool focused = false;
@ -578,9 +580,11 @@ namespace hex {
} }
// Handle global shortcuts // Handle global shortcuts
if (!popupOpen) {
for (const auto &key : this->m_pressedKeys) { for (const auto &key : this->m_pressedKeys) {
ShortcutManager::processGlobals(io.KeyCtrl, io.KeyAlt, io.KeyShift, io.KeySuper, key); ShortcutManager::processGlobals(io.KeyCtrl, io.KeyAlt, io.KeyShift, io.KeySuper, key);
} }
}
this->m_pressedKeys.clear(); this->m_pressedKeys.clear();
} }