From 58679760ff214683783b2b2c223dd8416bac007f Mon Sep 17 00:00:00 2001 From: Adrian Klingen Date: Sat, 3 Aug 2024 11:54:28 +0200 Subject: [PATCH] Add close on Escape --- UI.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/UI.lua b/UI.lua index 9e96c2f..81e22c3 100644 --- a/UI.lua +++ b/UI.lua @@ -46,6 +46,13 @@ function UI:CreateMainWindow(classIsSupported, simLink) frame:SetTitle("WowSimsExporter " .. Env.VERSION .. "") frame:SetStatusText("Click 'Generate Data' to generate exportable data") frame:SetLayout("Flow") + + -- Add the frame as a global variable under the name `WowSimsExporter` + _G["WowSimsExporter"] = frame.frame + -- Register the global variable `WowSimsExporter` as a "special frame" + -- so that it is closed when the escape key is pressed. + tinsert(UISpecialFrames, "WowSimsExporter") + _frame = frame local icon = AceGUI:Create("Icon") @@ -108,6 +115,9 @@ into the provided box and click "Import" jsonbox:SetFullWidth(true) jsonbox:SetFullHeight(true) jsonbox:DisableButton(true) + jsonbox.editBox:SetScript("OnEscapePressed", function(self) + OnClose(frame) + end) frame:AddChild(jsonbox) _jsonbox = jsonbox