Thread Tools Display Modes
03-17-11, 06:57 AM   #1
Kayja
A Deviate Faerie Dragon
Join Date: Jan 2009
Posts: 19
Duplicating a frame

I need to duplicate a frame, or take a "snapshot" of it when it's passed to a particular function, but I cannot seem to do it and need to fully recreate the frame and set all it's values using "Get" (like GetText() or GetTexture()).

I have it working how I want at the moment, but the only way I could get it to work was to build 2 seperate frames using the same config so they are identical, the second one however has no values set. When Frame #1 is passed to a particular function all of Frames #2's values are set to what Frame #1's are and Frame #2 is shown.

What I'm basically making is a castbar with a second interrupted bar identical to the first but colored red. Frame #1 is the main castbar, Frame #2 is an "interrupted bar", when a spell is interrupted Frame #1 is passed to a function then hidden (game auto hides it since no spell is being cast), and Frame #2 appears, gets colored red and takes all the values that were on the castbar, then slowly fades out.

Is there any way I can take a snapshot of Frame #1 which is used to make Frame #2 rather than having to build 2 seperate frames and make them identical?
  Reply With Quote
03-17-11, 08:41 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,334
I've recently scratched the surface of such an idea in the process of converting a normal button in the default UI into a SecureActionTemplate button in order to fix a bug with tradeskills not shifting a druid out of form and erroring out even with the relevant CVar set.

I've run into an interesting discovery while looking at how frame names and global registration through the frame name works when copying a frame using the same name.

Code:
print(CreateFrame("Frame","Test"));
print(Test);
print(CreateFrame("Frame","Test"));
print(Test);
Produces something like the following:
table: 2DA48CED
table: 2DA48CED
table: 2EAB5C32
table: 2DA48CED
Notice the first 2 and last pointer are the same. When creating a frame that shares the name of an existing frame, the global variable is left alone, yet the frame is created anyway.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 03-17-11 at 08:46 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Duplicating a frame


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off