WoW: Adding events to your frame
by Wuphon's Reach
First, you will need to create (2) functions in your Lua file:
function MyFrame_OnShow(self)The actual function names don't matter much here. You could have gone with "MyFrame.OnShow(self)", "MyFrame_DoOnShowStuff(self)", or a number of other versions. As long as you match up with the right function name in the next section, you'll be fine.
PlaySound("igQuestLogOpen");
end
function MyFrame_OnHide(self)
PlaySound("igQuestLogClose");
end
The other half of this is calling the "SetScript()" function in the Lua code where you are creating your frame. Most Add-ons have a function that does nothing but create the frame and populate it with controls and artwork. So, sometime after calling "CreateFrame()" and before you call "Show()", you'll want to insert the following two lines to call your event handling functions:
f:SetScript("OnShow",MyFrame_OnShow)Your frame will now make pretty quest log noises when it appears and disappears from the user's view. Make sure you pick something soothing and easy to listen to or it will get annoying very quickly.
f:SetScript("OnHide",MyFrame_OnHide)
Subscribe via RSS