Recent changes Random page
GAMING
Gaming
 
StarCraft Wiki
Super Smash Wiki
Halopedia
Diablo Wiki
FFXIclopedia
Grand Theft Wiki
See more...

Make Frames Closable With the "Esc" Key

From WoWWiki

Jump to: navigation, search

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

EditBoxes and OnEscapePressed

EditBox type frames have an "OnEscapePressed" handler, which will prevent this method from working with them. For these frames you can instead use:

 myeditboxframe:SetScript("OnEscapePressed", function(self) self:Hide() end)
Rate this article:
Share this article:
.