PDA

View Full Version : CreateFrame() API: It's a secret?!? Dont tell anyone....


syrioussam
03-10-2006, 10:15 PM
I am trying to write my own UI mod. I've understood all the tutorials i've read. I heard about the CreateFrame() api and decided to learn more about it. Editing frames in lua seems easier and much less prone to bugs than editing frames in XML. Plus my understanding is that you can reload your lua script while the client is running, not so for XML.

So most of the tutorials I've read are heavy on the XML. I'm trying to find out more about this CreateFrame API and what functions are available in LUA to do all the things that I've seen done in XML. Basically I'm looking for a list of functions that I can use on the frame "object" (is that what it's called in lua?) in order to set its characteristics, add widgets i.e. buttons, etc.

So far this is all I found, the one example on wowwiki:

-----------
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()
-----------

Does anyone know where I can go to find out what functions can be called on the frame object returned by CreateFrame() ? I have not found ANYTHING besides the above which although it shows promise of what might be possible, doesn't provide any kind of reference for discovering new functions.

I have put a couple hours into searching, so if there is a way to answer this question, I would greatly appreciate a direct answer such as:

Read the frameapi.lua file found inside frames.mpq
Read the webpage here: http://wow.interface.com/createframeapi.html
------------

And not one of these:

Look at how blizzard did it
Read the blizzard UI files
Its somewhere on the website here: http://home.wow.interface.com
----------------


Many thanks and looking forward to discovering what cool functions are available....!

vallerius
04-10-2006, 12:36 AM
Check out the "widget api" section of wowwiki, there's a boatload of documentation. In particular, look at the "region" part of that page, that has most of the general functions.

syrioussam
04-10-2006, 05:07 AM
Thank you, I reviewed that section more carefully and saw that the Frame object returned by CreateFrame did fit in with the "object" reference and hierarchy of what was on that page. I always didn't trust that page to be complete, but now I'm guessing that it IS complete.

Looking at the methods available to the Frame "object" and other things like Button, I'm guessing it is not possible to create your entire UI programmatically inculding buttons, checkboxes, layout, etc. You still have to define these in XML. It's ok i guess, wont stop me from doing what I wanted.

If someone could just confirm my findings that would be great :)

akx
04-10-2006, 06:14 AM
I see no real reason why it couldn't be possible. What exactly do you think is missing?

Wintrow
06-10-2006, 09:29 AM
I recon it'll be hard dynamically defining the eventhandlers.

Know that you can still define templates in XML and create your actual frames from those in LUA.

kosilveriarn
15-08-2007, 12:22 AM
I know its a bit of an old post....but anyone searching this now you can go here for the wow api (these functions should all work with lua)

http://www.wowwiki.com/World_of_Warcraft_API

Wodgar
15-08-2007, 12:59 AM
You can create buttons via the CreateFrame function - I don't see why you couldn't create checkbox style buttons especially if you use the right template in the above function.
Setting the scripts, etc. is also mostly straightforward.
Textures use the CreateTexture function as far as I remember.

WoWwiki is pretty good and it should be clear which functions don't have explanations yet.

I don't see that its better than XML necessarily, but each to their own ;)

I'm pretty certain XML file changes are reflected in ReloadUI, but changes Graphics resource files need a game re-start.

Moongaze
16-08-2007, 12:45 AM
You could create your entire addon, frames, buttons, dropdowns ... all of that, with straight LUA. However, you'll probably finding yourself using an existing Blizzard XML object as a template. It's faster, and kinda required for some functionality. So...

frame = CreateFrame("Frame", nil, UIParent);

Will make a frame, while you can do

frame = CreateFrame("Button", nil, UIParent);

To use the "Button" object as your base. In the LunarSphere addon I'm working on, pretty much everything is made with LUA calls. I decided to create some of my own XML objects as templates, mainly to save me some time. As people have mentioned, the wowwiki.com site is great for the API call documentation and some of their examples can push you in the right direction :)

ChaosInc
16-08-2007, 04:07 PM
Pst....

You can edit .xml, do a /reloadui and it will update your edits. I do it all the time when creating frames to get everything lined up correctly.