diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 4b2e90dff..4a7306cbe 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -355,8 +355,9 @@ namespace Hooks { static LRESULT thunk(HWND a_hwnd, UINT a_msg, WPARAM a_wParam, LPARAM a_lParam) { - if (a_msg == WM_KILLFOCUS) { - Menu::GetSingleton()->OnFocusLost(); + auto menu = Menu::GetSingleton(); + if (a_msg == WM_KILLFOCUS && menu->initialized) { + menu->OnFocusLost(); auto& io = ImGui::GetIO(); io.ClearInputKeys(); io.ClearEventsQueue(); diff --git a/src/Menu.cpp b/src/Menu.cpp index 6802a2b39..0c1a4531d 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -204,6 +204,8 @@ void Menu::Init(IDXGISwapChain* swapchain, ID3D11Device* device, ID3D11DeviceCon style.MouseCursorScale = 1.f; auto& io = ImGui::GetIO(); io.FontGlobalScale = trueScale; + + initialized = true; } void Menu::DrawSettings() diff --git a/src/Menu.h b/src/Menu.h index b9f767c9a..685b6520b 100644 --- a/src/Menu.h +++ b/src/Menu.h @@ -35,6 +35,8 @@ class Menu return &menu; } + bool initialized = false; + void Load(json& o_json); void Save(json& o_json);