WoW:API CreateFrame: Difference between revisions

m
Forgot a punctuation mark.
No edit summary
m (Forgot a punctuation mark.)
Line 3: Line 3:
Creates a new UI frame.
Creates a new UI frame.


  newFrame = CreateFrame("frameType", "frameName", parentFrame[, "inheritsFrame"]);
  newFrame = CreateFrame("frameType"[, "frameName"[, parentFrame[, "inheritsFrame"]]]);


== Parameters ==
== Parameters ==
=== Arguments ===
=== Arguments ===


:;frameType : String - Type of the frame to be created (XML tag name): "Frame", "Button"... etc.
:;frameType : String - Type of the frame to be created (XML tag name): "Frame", "Button", etc.
:;frameName : String - Name of the newly created frame. If nil, no frame name is assigned. Function will also set a global variable of this name to point to newly created frame.
:;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.
:;parentFrame : Frame - The frame object that will be used as the created Frame's parent (cannot be a string!)
:;parentFrame : Frame - The frame object that will be used as the created Frame's parent (cannot be a string!) If nil, UIParent is used.
:;inheritsFrame : String - a comma-delimited list of names of virtual frames to inherit from (the same as in XML), optional.
:;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 ===
Line 21: Line 21:
  local f = CreateFrame("Frame",nil,UIParent)
  local f = CreateFrame("Frame",nil,UIParent)
  f:SetFrameStrata("BACKGROUND")
  f:SetFrameStrata("BACKGROUND")
  f:SetWidth(128) -- Set These to whatever height/width is needed  
  f:SetWidth(128) -- Set these to whatever height/width is needed  
  f:SetHeight(64) -- for your Texture
  f:SetHeight(64) -- for your Texture
   
   
Line 35: Line 35:
* 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
* The frame's 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 using XML frames.
* The frame's 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 pointer is not necessary if you pass a frame name, however it is advised you store the pointer in a local instead of using the global name whenever possible for performance reasons.
* The returned pointer is not necessary if you pass a frame name, however it is advised you store the pointer in a local instead of using the global name whenever possible for performance reasons.
* The most common uses for this function are:
** Creating anonymous [[Events (API)|event handlers]].
** Creating anonymous [[Widget handlers|script handlers]].
** Creating frames on the fly for occasions when you don't know how many frames will be needed.
Anonymous user