Lore archive · Warcraft Wiki, 2023 dump
Make frames closable with the Escape key
Last wiki revision 2023-02-16
To make a frame close when the user presses the ESC (Escape) key, add its name to the table: tinsert(UISpecialFrames, frame:GetName) Note that in order for this to work, your frame must have a name and be registered in the global variable list.
The following XML snippet creates a frame that is closable by pressing Escape, and plays the sounds played when you open/close FrameXML panels (e.g. character frame). <Frame name="ExampleFrame" parent="UIParent"> <Size x="640" y="512" /> <Anchors> <Anchor point="CENTER" /> </Anchors> <Scripts> <OnLoad> tinsert(UISpecialFrames, self:GetName); </OnLoad> <OnShow> PlaySound(SOUNDKIT.IG_CHARACTER_INFO_OPEN); </OnShow> <OnHide> PlaySound(SOUNDKIT.IG_CHARACTER_INFO_CLOSE); </OnHide> </Scripts> </Frame>
The following lua snippet creates a frame that is closable by pressing Escape.
EditBox widgets that have focus will handle the Escape key being pressed by firing their own OnEscapePressed widget handler, preventing your frame from being closed while an edit box has focus. You may set your own OnEscapePressed handler on your edit boxes to hide a frame if necessary:
Source
https://warcraft.wiki.gg/wiki/Make_frames_closable_with_the_Escape_key · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.