feat: 输入隔离——ImGui WantCapture 在 Window 层门控事件与轮询

This commit is contained in:
2026-09-22 19:18:51 +08:00
parent 952ba8135d
commit 601fd8997c
3 changed files with 37 additions and 0 deletions
+8
View File
@@ -11,6 +11,8 @@
#include <Engine/Vulkan/Device.h>
#include <Engine/ImGui/ImGuiLayer.h>
#include <imgui.h>
#include <algorithm>
namespace Engine {
@@ -57,6 +59,12 @@ namespace Engine {
m_ImGuiLayer = CreateScope<ImGuiLayer>(GetWindow(), *m_Renderer);
m_Renderer->SetImGuiLayer(m_ImGuiLayer.get());
// 输入隔离:ImGui 想要的输入不再透给游戏侧
//(事件回调与轮询接口在 Window 层统一门控)
GetWindow().SetInputCapture(
[] { return ImGui::GetIO().WantCaptureKeyboard; },
[] { return ImGui::GetIO().WantCaptureMouse; });
}
void Application::Run()