WoW:Make Frames Closable With the "Esc" Key: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(example + some fancy work)
No edit summary
Line 31: Line 31:


the OnShow and OnHide parts will play the usual sound that's played when you open/close blizzards frames - e.g. your character frame
the OnShow and OnHide parts will play the usual sound that's played when you open/close blizzards frames - e.g. your character frame
==note==
This does not work for me.  Not even a little bit.  What I found *does* work is this simple bit of code added to any frame (in this example, 'testframe')
  testeditbox = CreateFrame("EditBox",nil,testframe,"InputBoxTemplate")
  testeditbox:SetScript("OnEscapePressed",function()
    testframe:Hide()
  end)


[[Category: HOWTOs|Make frames closable with the ESCape key]]
[[Category: HOWTOs|Make frames closable with the ESCape key]]

Revision as of 23:30, 28 September 2007

How To

To make your main frame closable with the ESCape key go into the OnLoad function and add the following line :

tinsert(UISpecialFrames,"MainFrameName");

where MainFrameName is the name of your main frame of the application.

Example

<Frame name="ExampleFrame" parent="UIParent">
	<Size>
		<AbsDimension x="640" y="512"/>
	</Size>
	<Anchors>
		<Anchor point="CENTER" />
	</Anchors>
	<Scripts>
		<OnLoad>
			tinsert(UISpecialFrames,this:GetName());
		</OnLoad>
		<OnShow>
			PlaySound("igCharacterInfoOpen");
		</OnShow>
		<OnHide>
			PlaySound("igCharacterInfoClose");
		</OnHide>
	</Scripts>
</Frame>

Description

this:GetName() returns the current UI Object's name and in this case our Frame Name. Using this will make the code more generic.

the OnShow and OnHide parts will play the usual sound that's played when you open/close blizzards frames - e.g. your character frame


note

This does not work for me. Not even a little bit. What I found *does* work is this simple bit of code added to any frame (in this example, 'testframe')


 testeditbox = CreateFrame("EditBox",nil,testframe,"InputBoxTemplate")
 testeditbox:SetScript("OnEscapePressed",function()
   testframe:Hide()
 end)