From d5d18e1712d57b071505aaa562865f0cc22da122 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Wed, 1 Sep 2021 16:01:01 +0200 Subject: [PATCH] feat: add Window.IsFocused --- Dalamud/Interface/Windowing/Window.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index 2efa38ff3..ec9115d8d 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -43,6 +43,11 @@ namespace Dalamud.Interface.Windowing /// public string WindowName { get; set; } + /// + /// Gets a value indicating whether the window is focused. + /// + public bool IsFocused { get; private set; } + /// /// Gets or sets the position of this window. /// @@ -188,8 +193,10 @@ namespace Dalamud.Interface.Windowing // Draw the actual window contents this.Draw(); + this.IsFocused = ImGui.IsWindowFocused(); + var escapeDown = Service.Get()[VirtualKey.ESCAPE]; - if (escapeDown && ImGui.IsWindowFocused() && !wasEscPressedLastFrame) + if (escapeDown && this.IsFocused && !wasEscPressedLastFrame) { this.IsOpen = false; wasEscPressedLastFrame = true;