Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,14 @@ void Menu::ProcessInputEventQueue()
}
}

// Close menu with ESC if no editor window is open
// Handle ESC key for menu and editor window
auto* editorWindow = EditorWindow::GetSingleton();
if (key == VK_ESCAPE && IsEnabled && editorWindow && !editorWindow->open) {
IsEnabled = false;
if (key == VK_ESCAPE) {
if (editorWindow && editorWindow->open && editorWindow->ShouldHandleEscapeKey()) {
editorWindow->open = false;
} else if (IsEnabled && (!editorWindow || !editorWindow->open)) {
IsEnabled = false;
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/WeatherEditor/EditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,6 @@ void EditorWindow::RenderUI()
// Increase background opacity for all editor windows
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.0f);

// Check for Escape key to close editor (but not if a popup is open)
if (ImGui::IsKeyPressed(ImGuiKey_Escape, false) && !ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel)) {
open = false;
}

// Check for Ctrl+Z to undo
if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) && ImGui::IsKeyPressed(ImGuiKey_Z, false)) {
if (CanUndo()) {
Expand Down Expand Up @@ -1634,6 +1629,11 @@ void EditorWindow::RestoreVanityCamera()
}
}

bool EditorWindow::ShouldHandleEscapeKey() const
{
return !ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel);
}

void EditorWindow::PushUndoState(Widget* widget)
{
if (!widget)
Expand Down
3 changes: 3 additions & 0 deletions src/WeatherEditor/EditorWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class EditorWindow
/// Draw the full time controls panel (pause, game time, timescale).
void DrawTimeControls();

// Check if ESC key should close the editor (no popups open)
bool ShouldHandleEscapeKey() const;

void DisableVanityCamera();
void RestoreVanityCamera();

Expand Down
Loading