Thread Tools Display Modes
01-04-07, 05:54 AM   #1
MartijnGP
A Kobold Labourer
Join Date: Jan 2007
Posts: 1
How to find a frame's children?

I need to know all the children of the Minimap frame. When looking around I found the function API GetChildren(), but I can't get it to work. I tried the following script in a macro to see if it would have any result at all.

Code:
/run kids = { Minimap:GetChildren() };for _,framechild in ipairs(kids) do mgui_consolemsg("-"..framechild); end
Note: the mgui_consolemsg function prints the input into the chatframe, and I'm 100% sure that works, so that's not the problem.

Which should, according to explanations I found about this function, print a list of names of the frames that have the minimap as their parent. But it doesn't, it says the framechild is a table value, but when I extract that using foreach, it's completely empty.

Does anyone know how to fix this, or possibly another way to find which frames have the Minimap as parent? It doesn't need to be a fast and efficient code, as it will only be ran once during the installation part of this addon, and not during gameplay.
 
01-04-07, 01:52 PM   #2
pert
A Murloc Raider
 
pert's Avatar
Join Date: Apr 2006
Posts: 5
Try this:
Code:
/run kids = { Minimap:GetChildren() };for _,framechild in ipairs(kids) do mgui_consolemsg("-"..framechild:GetName() ); end
GetChildren does not return the name of the frames, but the actual frame tables themselves.

My guess is, when you try to write them out as a string, the metatable will be searched for a __tostring method, which most likely has not been overwritten. The default __tostring method will then just be called, and that just tells you what and where it is ( "table" and some numbers )

/PerT
 
04-26-18, 03:59 AM   #3
dogmax
A Kobold Labourer
Join Date: Sep 2007
Posts: 1
You can make a useful macro that will print the names of the children of a frame you a hovering with your mouse.


This is the code you need to put in your macro:

Code:
/run function kiddos () local kiddos = { GetMouseFocus():GetChildren() }; for _, child in ipairs(kiddos) do DEFAULT_CHAT_FRAME:AddMessage(child:GetName()); end end kiddos();
It's a bit hard to decipher because code that you run in a macro needs to be on the same line.

If you want to understand the code, then here it is with multiple lines and indentations:


Code:
function kiddos () 
    local kiddos = { GetMouseFocus():GetChildren() };
    for _, child in ipairs(kiddos) do 
        DEFAULT_CHAT_FRAME:AddMessage(child:GetName());
    end
end

Then you can run the code from the chatbox like this:


Code:
/run kiddos();
Which will print the names of the child frames in the chat.
 
04-26-18, 04:47 AM   #4
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
You could, also, try the "framestack" command (/framestack or /fstack [for short command]). Type it in, then just put your mouse over the minimap and hit the "enter" key. That should open a new window (in one of the corners of the screen) that will give you everything that is currently under your cursor. Just run the command again to shut it down. I don't know if it will give you the children of the minimap, but it's worth a shot.

NUTS!! I didn't see that the original post was made in January! I doubt that the original poster is still looking for an answer but I gave him one anyway.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!

Last edited by jeffy162 : 04-26-18 at 04:56 AM. Reason: more blah blah blah.
 
04-26-18, 12:33 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by jeffy162 View Post
NUTS!! I didn't see that the original post was made in January! I doubt that the original poster is still looking for an answer but I gave him one anyway.
Not just January. ELEVEN years ago.
__________________
"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

 
04-27-18, 10:18 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by jeffy162 View Post
I doubt that the original poster is still looking for an answer but I gave him one anyway.
This still holds true, though.

I'm going to go ahead and close this.
__________________
"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

 
04-26-18, 01:11 PM   #7
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
OH!! I didn't see THAT though. DOH!!
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
 

WoWInterface » Developer Discussions » Lua/XML Help » How to find a frame's children?


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