mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-31 21:03:43 +01:00
feat: escape to close topmost window in WindowSystem
This commit is contained in:
parent
559b5e2904
commit
de27e383b2
1 changed files with 14 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
|
using Dalamud.Game.ClientState.Keys;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Windowing
|
namespace Dalamud.Interface.Windowing
|
||||||
|
|
@ -9,6 +10,8 @@ namespace Dalamud.Interface.Windowing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class Window
|
public abstract class Window
|
||||||
{
|
{
|
||||||
|
private static bool wasEscPressedLastFrame = false;
|
||||||
|
|
||||||
private bool internalLastIsOpen = false;
|
private bool internalLastIsOpen = false;
|
||||||
private bool internalIsOpen = false;
|
private bool internalIsOpen = false;
|
||||||
|
|
||||||
|
|
@ -169,6 +172,17 @@ namespace Dalamud.Interface.Windowing
|
||||||
{
|
{
|
||||||
// Draw the actual window contents
|
// Draw the actual window contents
|
||||||
this.Draw();
|
this.Draw();
|
||||||
|
|
||||||
|
var escapeDown = Service<KeyState>.Get()[VirtualKey.ESCAPE];
|
||||||
|
if (escapeDown && ImGui.IsWindowFocused() && !wasEscPressedLastFrame)
|
||||||
|
{
|
||||||
|
this.IsOpen = false;
|
||||||
|
wasEscPressedLastFrame = true;
|
||||||
|
}
|
||||||
|
else if (!escapeDown && wasEscPressedLastFrame)
|
||||||
|
{
|
||||||
|
wasEscPressedLastFrame = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue