Automated updating of API pages at this location, to reflect patch changes, has ceased from 10.1.7 onwards. |
Creates a Frame object.
frame = CreateFrame(frameType [, name, parent, template, id])
Arguments[]
- frameType
- string - Type of the frame; e.g. "Frame" or "Button".
- name
- string? - Globally accessible name to assign to the frame, or
nil
for an anonymous frame. - parent
- Frame?🔗 - Parent object to assign to the frame, or
nil
to be parentless; cannot be a string. Can also be set with Region:SetParent() - template
- string? - Comma-delimited list of virtual XML templates to inherit; see also a complete list of FrameXML templates.
- id
- number? - ID to assign to the frame. Can also be set with Frame:SetID()
Returns[]
- frame
- Frame🔗 - The created Frame object or one of the other frame type objects.
Frame types[]
Possible frame types are available from the XML schema {, }:
|
|
Details[]
- Fires the frame's OnLoad script, if it has one from an inherited template.
- Frames cannot be deleted or garbage collected, so it may be preferable to reuse them.
- Intrinsic frames may also be used.
Example[]
- Shows a texture which is also parented to UIParent so it will be have the same UI scale and hidden when toggled with
Alt-Z
local f = CreateFrame("Frame", nil, UIParent)
f:SetPoint("CENTER")
f:SetSize(64, 64)
f.tex = f:CreateTexture()
f.tex:SetAllPoints(f)
f.tex:SetTexture("interface/icons/inv_mushroom_11")
- Creates a button which inherits textures and widget scripts from UIPanelButtonTemplate
local btn = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
btn:SetPoint("CENTER")
btn:SetSize(100, 40)
btn:SetText("Click me")
btn:SetScript("OnClick", function(self, button, down)
print("Pressed", button, down and "down" or "up")
end)
btn:RegisterForClicks("AnyDown", "AnyUp")
- Displays an animated model for a DisplayID.
local m = CreateFrame("PlayerModel")
m:SetPoint("CENTER")
m:SetSize(200, 200)
m:SetDisplayInfo(21723) -- murloccostume.m2
- Registers for events being fired, like chat messages and when you start/stop moving.
local function OnEvent(self, event, ...)
print(event, ...)
end
local f = CreateFrame("Frame")
f:RegisterEvent("CHAT_MSG_CHANNEL")
f:RegisterEvent("PLAYER_STARTED_MOVING")
f:RegisterEvent("PLAYER_STOPPED_MOVING")
f:SetScript("OnEvent", OnEvent)
Patch changes[]
Patch 2.0.1 (2006-12-05): The fourth argument, inheritFrame, now accepts comma-separated values.
Patch 1.11.0 (2006-06-19): Added fourth argument, inheritFrame.[1]
Patch 1.10.0 (2006-03-28): Added.[2]
See also[]
References[]
- ^ slouken 2006-05-23. Re: Upcoming 1.11 Changes - Concise List. Archived from the original
- ^ Iriel 2005-12-28. Upcoming 1.10 Changes - Concise List. Archived from the original