Trying to find an event that I can register and listen for that will trigger when the keystone window opens - I need to move the frame since it is behind my other UI elements. If I put it to load on PLAYER_ENTERING_WORLD the ChallengesKeystoneFrame is a nil value
Does anyone know of / can think of an event to use?
There isnāt an event for it, but you can HookScript the OnShow event of ChallengesKeystoneFrame, and you can register an event handler for when the Blizzard_ChallengesUI addon is loaded (ie, when ChallengesKeystoneFrame becomes available).
Hereās how AngryKetstones does its thing to insert the keystone:
hmm looks very promising, donāt quite get it to work - do I call the StartUp function somewhere for it to work? I also assume I have to remove the āModā thing they define?
EDIT: to clarify I guess I just donāt quite get how to add hte event handler - the rest is clear
EDIT2: I looked more into the rest of their source code and found the correct event to listen to and got it to work, thanks for the help!
local f = CreateFrame("Frame")
local function fixFrame()
ChallengesKeystoneFrame:SetFrameLevel(1000)
end
local function insertKeystone()
if ChallengesKeystoneFrame then
ChallengesKeystoneFrame:HookScript("OnShow", function()
for Bag = 0, NUM_BAG_SLOTS do
for Slot = 1, GetContainerNumSlots(Bag) do
local ID = GetContainerItemID(Bag, Slot)
if (ID and ID == 180653) then
return UseContainerItem(Bag, Slot)
end
end
end
end)
f:UnregisterEvent("ADDON_LOADED")
end
end
local function OnEvent(self, event, addon)
if event == "ADDON_LOADED" and addon == "Blizzard_ChallengesUI" then
insertKeystone()
end
if event == "CHALLENGE_MODE_KEYSTONE_RECEPTABLE_OPEN" then
fixFrame()
end
end
f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("CHALLENGE_MODE_KEYSTONE_RECEPTABLE_OPEN")
f:SetScript("OnEvent", OnEvent)
This raises the frame level and inserts the stone.