Close the window when Escape is pressed
Register the main frame ("AmibisMainFrame") in UISpecialFrames so Escape
hides it and suppresses the game menu while it is open, matching the
default UI panels.
Move the stats-retry timer cleanup into the frame's OnHide script so the
close button, Escape, and /amibis all stop the timer.
Tests: the mock now registers named frames in _G and runs OnHide scripts.
The UI suite simulates FrameXML's CloseSpecialWindows() and asserts the
frame hides and the retry timer is cleared. 108 passing.
This commit is contained in:
1 parent
cc3971fe93
commit
d8fefc947e
6 files changed
+77
-9
No files matched your search
@@ -52,6 +52,27 @@ local function CreateMainFrame()
|
||||
self:StopMovingOrSizing()
|
||||
Amibis:SaveFramePosition(self)
|
||||
end)
|
||||
frame:SetScript("OnHide", function()
|
||||
if Amibis._statsRetryTimer then
|
||||
Amibis._statsRetryTimer:Hide()
|
||||
Amibis._statsRetryTimer = nil
|
||||
end
|
||||
end)
|
||||
|
||||
-- Registering with UISpecialFrames makes the Escape key close the window
|
||||
-- (and suppresses the game menu, like the default UI panels).
|
||||
if UISpecialFrames then
|
||||
local registered = false
|
||||
for _, name in ipairs(UISpecialFrames) do
|
||||
if name == "AmibisMainFrame" then
|
||||
registered = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not registered then
|
||||
table.insert(UISpecialFrames, "AmibisMainFrame")
|
||||
end
|
||||
end
|
||||
|
||||
frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
|
||||
return frame
|
||||
@@ -584,11 +605,8 @@ function ns.UI.ToggleFrame()
|
||||
end
|
||||
|
||||
if MainFrame:IsShown() then
|
||||
-- Hiding runs the frame's OnHide script, which stops the stats retry timer.
|
||||
MainFrame:Hide()
|
||||
if Amibis._statsRetryTimer then
|
||||
Amibis._statsRetryTimer:Hide()
|
||||
Amibis._statsRetryTimer = nil
|
||||
end
|
||||
else
|
||||
MainFrame:Show()
|
||||
Amibis._statsRetryAttempts = nil
|
||||
|
||||
Reference in new issue
Block a user