Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
(list)
Line 16: Line 16:
   
 
:;newFrame : Frame - Pointer to the newly created frame.
 
:;newFrame : Frame - Pointer to the newly created frame.
  +
  +
Note: the pointer is not necessary. Simply using CreateFrame(...) will suffice.
   
 
== Example ==
 
== Example ==

Revision as of 00:34, 22 April 2008

Creates a new UI frame.

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

Parameters

Arguments

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.
parentFrame
Frame - The frame object that will be used as the created Frame's parent (cannot be a string!)
inheritsFrame
String - a comma-delimited list of names of virtual frames to inherit from (the same as in XML), optional.

Returns

newFrame
Frame - Pointer to the newly created frame.

Note: the pointer is not necessary. Simply using CreateFrame(...) will suffice.

Example

Result: displays the horde and alliance insignias in the middle of the screen.

local f = CreateFrame("Frame",nil,UIParent)
f:SetFrameStrata("BACKGROUND")
f:SetWidth(128)  -- Set These to whatever height/width is needed 
f:SetHeight(64) -- for your Texture

local t = f:CreateTexture(nil,"BACKGROUND")
t:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Factions.blp")
t:SetAllPoints(f)
f.texture = t

f:SetPoint("CENTER",0,0)
f:Show()

Notes

  • CreateFrame() was added in 1.10
  • 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.