m
Move page script moved page API CreateFrame to WoW:API CreateFrame without leaving a redirect
m (→Notes) |
m (Move page script moved page API CreateFrame to WoW:API CreateFrame without leaving a redirect) |
||
| (4 intermediate revisions by 4 users not shown) | |||
| Line 8: | Line 8: | ||
=== Arguments === | === Arguments === | ||
:;frameType : String - Type of the frame to be created (XML tag name): "Frame", "Button", etc. | :;frameType | ||
:;frameName : String - Name of the newly created frame. If nil, no frame name is assigned. The function will also set a global variable of this name to point to newly created frame. | :: String - Type of the frame to be created (XML tag name): "Frame", "Button", etc. See [[UIOBJECT_Frame]] | ||
:;parentFrame : Frame - The frame object that will be used as the created Frame's parent (cannot be a string!) Does not default to UIParent if given nil. | :;frameName | ||
:;inheritsFrame : String - a comma-delimited list of names of virtual frames to inherit from (the same as in XML). If nil, no frames will be inherited. These frames cannot be frames that were created using this function, they must be created using XML with '''virtual="true"''' in the tag. | :: String - Name of the newly created frame. If nil, no frame name is assigned. The function will also set a global variable of this name to point to the newly created frame. | ||
:;parentFrame | |||
:: Frame - The frame object that will be used as the created Frame's parent (cannot be a string!) Does not default to UIParent if given nil. | |||
:;inheritsFrame | |||
:: String - a comma-delimited list of names of virtual frames to inherit from (the same as in XML). If nil, no frames will be inherited. These frames cannot be frames that were created using this function, they must be created using XML with '''virtual="true"''' in the tag. | |||
=== Returns === | === Returns === | ||
:;newFrame : Frame - | :;newFrame | ||
:: Frame - Reference to the newly created frame. | |||
== Example == | == Example == | ||
Result: displays the horde and alliance insignias in the middle of the screen. | Result: displays the horde and alliance insignias in the middle of the screen. | ||
local f = CreateFrame("Frame",nil,UIParent) | local f = CreateFrame("Frame",nil,UIParent) | ||
| Line 35: | Line 40: | ||
* CreateFrame() was added in 1.10 | * CreateFrame() was added in 1.10 | ||
* The fourth argument, inheritFrame, was added in 1.11 | * The fourth argument, inheritFrame, was added in 1.11 | ||
* Frames CANNOT be deleted. Reuse them. | |||
* The frame's [[UIHANDLER_OnLoad|OnLoad handler]], which will only exist if inherited, will be executed during the CreateFrame call. Any OnLoad script handlers set after CreateFrame() will not execute; consider adding any non-inherited OnLoad code directly after a CreateFrame call or use XML frames instead. | * The frame's [[UIHANDLER_OnLoad|OnLoad handler]], which will only exist if inherited, will be executed during the CreateFrame call. Any OnLoad script handlers set after CreateFrame() will not execute; consider adding any non-inherited OnLoad code directly after a CreateFrame call or use XML frames instead. | ||
* The returned | * The returned frame reference is not strictly necessary because you can access frames by their global name if you give them one. For performance reasons, however, it is advised to store frame references in local variables and use those instead of getting frames by their global name. | ||
* See also [[API_Frame_SetScript]] to handle OnFunction scripts when not using a template. | * See also [[API_Frame_SetScript]] to handle OnFunction scripts when not using a template. | ||
* The most common uses for this function are: | * The most common uses for this function are: | ||