feat: add Window.IsFocused

This commit is contained in:
goat 2021-09-01 16:01:01 +02:00
parent d2597f7520
commit d5d18e1712
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -43,6 +43,11 @@ namespace Dalamud.Interface.Windowing
/// </summary>
public string WindowName { get; set; }
/// <summary>
/// Gets a value indicating whether the window is focused.
/// </summary>
public bool IsFocused { get; private set; }
/// <summary>
/// Gets or sets the position of this window.
/// </summary>
@ -188,8 +193,10 @@ namespace Dalamud.Interface.Windowing
// Draw the actual window contents
this.Draw();
this.IsFocused = ImGui.IsWindowFocused();
var escapeDown = Service<KeyState>.Get()[VirtualKey.ESCAPE];
if (escapeDown && ImGui.IsWindowFocused() && !wasEscPressedLastFrame)
if (escapeDown && this.IsFocused && !wasEscPressedLastFrame)
{
this.IsOpen = false;
wasEscPressedLastFrame = true;