Fix input handling

Keyboard input is blocked when a menu is receiving text input
Mouse inputs are blocked when the mouse is visible and hovering over an imgui item
This commit is contained in:
2024-11-24 02:28:22 -05:00
parent 4285dafeb6
commit 606e2e0b9f
2 changed files with 43 additions and 1 deletions

View File

@@ -18,6 +18,11 @@ internal class ImGuiHandler : IDisposable
private DeviceContext? _deviceContext;
private static nint _wndproc;
public bool BlockMouse { get; private set; }
public bool BlockKeys { get; private set; }
public bool DrawMouse { get; private set; }
public static ImGuiHandler? Instance;
public static RenderTargetView? Rtv;
@@ -65,7 +70,11 @@ internal class ImGuiHandler : IDisposable
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
NewFrame();
var io = GetIO();
BlockMouse = io.WantCaptureMouse;
BlockKeys = io.WantTextInput;
DrawMouse = io.MouseDrawCursor;
_renderHandler.OnFrame();
Render();