feat: release ImGui focus when clicking into game

This commit is contained in:
goat 2021-09-11 03:04:35 +02:00
parent 8bc4598a3c
commit eb11857bac
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5

View file

@ -17,6 +17,7 @@ using Dalamud.Plugin.Internal;
using Dalamud.Utility;
using ImGuiNET;
using ImGuiScene.ManagedAsserts;
using PInvoke;
using Serilog.Events;
namespace Dalamud.Interface.Internal
@ -316,6 +317,13 @@ namespace Dalamud.Interface.Internal
if (this.isImGuiDrawDemoWindow)
ImGui.ShowDemoWindow();
// Release focus of any ImGui window if we click into the game.
var io = ImGui.GetIO();
if (!io.WantCaptureMouse && (User32.GetKeyState((int)User32.VirtualKey.VK_LBUTTON) & 0x8000) != 0)
{
ImGui.SetWindowFocus(null);
}
}
catch (Exception ex)
{
@ -479,6 +487,11 @@ namespace Dalamud.Interface.Internal
ImGui.MenuItem("Enable Asserts", string.Empty, ref ImGuiManagedAsserts.EnableAsserts);
if (ImGui.MenuItem("Clear focus"))
{
ImGui.SetWindowFocus(null);
}
ImGui.EndMenu();
}