Thread Tools Display Modes
01-23-10, 07:29 PM   #1
nehegeb
A Murloc Raider
Join Date: Nov 2009
Posts: 9
useful Macro for checking UI-Items

Hi there!

Here is a useful Macro, for getting the name of a UI frame:

/script DEFAULT_CHAT_FRAME:AddMessage( GetMouseFocus():GetName() );

Just create that Macro and put it into the actionbar. Point your mousecursor over a particular frame an press the actionbars number for that Macro. The frames name will be post into the chatframe.

But now I have got a question:

I need a Macro for getting the texturepath from the texture my mouse is over. The following Macro doesn't work but I don't know why:
/script DEFAULT_CHAT_FRAME:AddMessage( GetMouseFocus():GetTexture() );
All I found out so far is that 'GetTexture()' seems to not work with 'GetMouseFocus()'. But why?
The following works:
/script DEFAULT_CHAT_FRAME:AddMessage( ActionButton1Icon:GetTexture() );
This Macro gets the texturepath of the icon in actionbar1.

I hope that Macro helps you and someone can help me!
greetings, nehegeb
  Reply With Quote
01-23-10, 08:35 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
GetTexture() only works for texture objects. Frame objects do not use SetTexture(). They have a background image and use SetBackdrop() instead. So, if your GetTexture() doesn't work, use GetBackdrop().
__________________
"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
01-23-10, 08:55 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Your first macro actually fails because GetMouseFocus() does not return ActionButton1Icon. It returns ActionButton1.

GetMouseFocus() only returns the top-most mouse-enabled frame. It doesn't return non-frame UI objects (like textures or font strings). It doesn't return frames that aren't mouse-enabled. And it only returns the mouse-enabled frame with the highest frame level/strata.

Since ActionButton1Icon is a texture, not a frame, you won't get a pointer to it from GetMouseFocus().

However, Seerah's solution won't work for your particular case, because ActionButton1Icon is a child of what GetMouseFocus() does return (ActionButton1), not its backdrop. There isn't really a generic solution that will work to get all visible textures. If you're only interested in action button icon textures, the following would work:

/print _G[GetMouseFocus():GetName() .. "Icon"]:GetTexture()

Breaking that down:
  1. GetMouseFocus() returns the frame object.
  2. :GetName() returns the name of the object it's called on; in this case, the frame object.
  3. The string concatenation operator (..) appends "Icon" onto the end of the name.
  4. The table lookup in _G returns the object whose name in the global namespace matches the provided table key; in this case, a string consisting of the button's name with "Icon" on the end, which points to the texture object that serve's the button's icon.
  5. :GetTexture() returns the texture of the object it's called on.

Note that using this macro on objects that don't have a name will cause an error. Using it on objects that do have a name, but don't have a corresponding "nameIcon" object, will also cause an error.
  Reply With Quote
01-24-10, 03:50 AM   #4
nehegeb
A Murloc Raider
Join Date: Nov 2009
Posts: 9
Thanks for your rapid answers!

@Seerah:
Sadly your tip with 'GetBackdrop()' doesnt work. That would have been great!

@Phanx:
Thanks for your infos. They will help me further!

But I think, I didn't explain correctly what I need...
...in general I need a Macro that tells me, what texturepath a visible texture on the UI has got, so that I can use exactly this texture for my addons. At first it would really help me, if I could get just the path of the texture on the hightest level/strata. So maybe the thing with 'GetMouseFocus()' could work.

I don't only need just the Icons. That was just an example for what worked (in my first post). In many cases it's really just the backdrop of a frame.

Maybe what I want isn't possible for a single Macro, so an Addon also would do it, if it exists. Otherwise I have to break my workings on my almost finished Addon and build another one that gets me my needed textures. The perfect solution would be a Tooltip next to the mousecursor, that shows me all the UI textures and their paths from what my mouse is pointing at (from all strata).

btw. my first macro is helpful, if you want to know how a particular frame is called for maybe anchoring another frame to this one.
  Reply With Quote
01-24-10, 04:08 AM   #5
cag_dk
A Deviate Faerie Dragon
 
cag_dk's Avatar
Join Date: Jan 2006
Posts: 14
FluidFrames ???

Doesn't FluidFrames do what ya want?
__________________
King for a Day, Fool for a Lifetime
  Reply With Quote
01-24-10, 04:50 AM   #6
nehegeb
A Murloc Raider
Join Date: Nov 2009
Posts: 9
No, not really. This addon moves frames in the UI but I need the textures (texturepaths) that are used for those frames to use them in my own addons.
  Reply With Quote
01-24-10, 04:55 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by nehegeb View Post
...in general I need a Macro that tells me, what texturepath a visible texture on the UI has got, so that I can use exactly this texture for my addons.
Well, if you're trying to figure out which textures are used by default UI stuff, you could just look at Blizzard's code.

http://wowcompares.com/

Otherwise, you're going to run into tons of issues trying to use macros to find textures. Some textures are Backdrops, while others are StatusBarTextures, and others are Texture regions that are either unnamed or don't follow any consistent naming pattern. There's pretty much no way to write a macro that will catch all of those cases and correctly identify which of a frame's child Texture regions you want.
  Reply With Quote
01-24-10, 05:40 AM   #8
nehegeb
A Murloc Raider
Join Date: Nov 2009
Posts: 9
Thank you, Phanx! Your link is quite useful.
Checking those files will take a while, but it's a start!

Edith asks:
Is there a site or program or whatever for seeing all the WoW textures with their paths? Or where do other addon-coder get their textures from (if they are not self-made)?

Last edited by nehegeb : 01-24-10 at 06:00 AM.
  Reply With Quote
01-24-10, 10:56 AM   #9
Aesh
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Nov 2009
Posts: 11
if you need to see textures
try this :
http://us.blizzard.com/support/artic...rticleId=21466

for converting BLP's to PNG i am using this litle program,maybe bit old but working very good for me.

http://www.wowinterface.com/download...7-BLP2PNG.html
  Reply With Quote
01-24-10, 11:51 AM   #10
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Yep, extracting the UI art is a good idea. That will also allow you to extract the UI code (which is what Phanx linked you to, but that site shows you diffs between versions of the game).

There is also this to allow you to browse them online: http://wowprogramming.com/utils/artbrowser

(note, on the site I linked above, the path would start with Interface\... followed by the folders/files listed on that page)
__________________
"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
01-24-10, 12:04 PM   #11
ArrchDK
A Fallenroot Satyr
 
ArrchDK's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 25
Code:
/run
local function child(f) 
    if f:GetObjectType() == "Texture" then 
        print(f:GetTexture()) 
    else 
        local c = { f:GetChildren() } 
        for i = 1, getn(c) do 
            child(c[i])
        end
    end 
end
child(GetMouseFocus())
Untested, but it's a rough idea on how to do it. Basically just use recursion to walk the tree and find an object that is a texture. Remove the white space before testing, of course.
  Reply With Quote
02-01-10, 12:34 PM   #12
nehegeb
A Murloc Raider
Join Date: Nov 2009
Posts: 9
Thank you very much for all of your help!

Your links and tips really helped me. Now my addon looks quite cool

Greetings nehegeb
  Reply With Quote
02-01-10, 12:56 PM   #13
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
/framestack
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » useful Macro for checking UI-Items

Thread Tools
Display Modes

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