Event that captures keystone window opening

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:

https://github.com/Ermad/angry-keystones/blob/master/Keystone.lua#L49-L70

You can modify the SlotKeystone function to move the frame or whatever else you wish to do with it.

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! :smiley:

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.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.