Skip to content

Commit

Permalink
#42: fixed petId issue and added esc handler (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
berickus authored Jul 5, 2024
1 parent cc08593 commit 576cc21
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ function Saddlebag:GetUpdatedListingsJson()
if (not has_value(private.ignoredAuctions, v["auctionID"]))
then
local item_data = {}
if v["itemKey"]["battlePetSpeciesID"] then
item_data.petID = v["itemKey"]["battlePetSpeciesID"]
else
if v["itemKey"]["battlePetSpeciesID"] == 0 then
item_data.itemID = v["itemKey"]["itemID"]
else
item_data.petID = v["itemKey"]["battlePetSpeciesID"]
end
item_data.price = v["buyoutAmount"]
item_data.auctionID = v["auctionID"]
Expand Down Expand Up @@ -237,6 +237,7 @@ function Saddlebag:auctionButton(text)
f:SetWidth(frameConfig.width)
f:SetHeight(frameConfig.height)
f:SetAutoAdjustHeight(true)
Saddlebag:SetEscapeHandler(f, function() Saddlebag:auctionButton(""):Hide() end)

-- load position from local DB
f:SetPoint(
Expand Down Expand Up @@ -465,3 +466,22 @@ buttonPopUpFrame2:RegisterEvent("OWNED_AUCTIONS_UPDATED")
buttonPopUpFrame2:SetScript("OnEvent", function()
Saddlebag:GetUpdatedListingsJson()
end)

----------------------------------------------------------------------------------
-- AceGUI hacks --

-- hack to hook the escape key for closing the window
function Saddlebag:SetEscapeHandler(widget, fn)
widget.origOnKeyDown = widget.frame:GetScript("OnKeyDown")
widget.frame:SetScript("OnKeyDown", function(self, key)
widget.frame:SetPropagateKeyboardInput(true)
if key == "ESCAPE" then
widget.frame:SetPropagateKeyboardInput(false)
fn()
elseif widget.origOnKeyDown then
widget.origOnKeyDown(self, key)
end
end)
widget.frame:EnableKeyboard(true)
widget.frame:SetPropagateKeyboardInput(true)
end

0 comments on commit 576cc21

Please sign in to comment.