Thread Tools Display Modes
09-10-09, 09:20 AM   #1
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
How to removes frames at runtime

Hi all,

The last thing that stops me from finishing my addon is how to add/remove frames into a parent frame.

The parent frame has an editbox and a "add" button, in order to add stuff to a table. Whenever this table is modified, I need to print all its content in a list attaching a "delete" button.

The thing is, I know hoe to ADD frames programatically, but have no idea how the delete all child frames in order to redraw the new modifies list.

Any help? Thanks!
  Reply With Quote
09-10-09, 09:31 AM   #2
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
What Blizzard seemed to do most of the time when I read their code was to create a table that contains references to a certain (usually fixed) number of frames. Whenever a frame is "added", you take the next frame in the table, configure it and show it. Whenever a frame is "removed", you hide it and update the table. Basically, you simulate the creation and deletion by playing with :Hide() and :Show() on static objects.

I guess there are better ways to do that though, but it works well if you don't mind having several hidden frames with no real use.
  Reply With Quote
09-10-09, 09:33 AM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You can set a frame reference to nil, but you cannot "delete" or "destroy" a frame. You'll need to set up a recycling system of sorts.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-10-09, 11:00 AM   #4
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
Thanks you all! What I'm finally doing is create a frame that parents the list, and each time the list is refreshed hide it and create a new one.

I've never seen anything such inefficient... but it works :P
  Reply With Quote
09-10-09, 11:30 AM   #5
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by MigGat View Post
Thanks you all! What I'm finally doing is create a frame that parents the list, and each time the list is refreshed hide it and create a new one.

I've never seen anything such inefficient... but it works :P
Doing it that way is not inefficient to the point that it will break things; but it would be better to keep the old ones and use them again instead of creating a new one each time.
  Reply With Quote
09-10-09, 12:15 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Akryn View Post
but it would be better to keep the old ones and use them again instead of creating a new one each time.
This ^^. Hence the term "recycling" in my post above. This is also what Layrajha was implying.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How to removes frames at runtime


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