Thread Tools Display Modes
12-14-10, 04:22 AM   #1
barbol12
A Cyclonian
 
barbol12's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 42
parent frame...

how would you set a frame(made entirely in lua) to parent to bartender4 pet bar???

ive tried

pet:SetParent("BT4PetButton1")

also tried these:
"PetActionBar"
"PetBar"

but nothing works.... someone know what to properly put in for the parent?
  Reply With Quote
12-14-10, 04:57 AM   #2
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
You could either decipher the Bartender code to try and find the correct name, or...

In game type '/framestack' in the chat box (without quotes) and then move the mouse pointer over the pet bar. This will show the names of all the frames under the mouse pointer. Trying '/framestack' again will turn off the functionality.
  Reply With Quote
12-14-10, 05:01 AM   #3
barbol12
A Cyclonian
 
barbol12's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 42
nice.. but it still comes up with the same thing....

BT4PetButton1.. etc etc

ive tried that to set my frame to that parent... but it does not work.

pet:SetParent("BT4PetButton1") doesnt work.... for some reason.
  Reply With Quote
12-14-10, 05:03 AM   #4
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
Is your addon loading before Bartender? If so the parent frame you are trying to set may not exist yet.

Make sure Bartender loads before your addon by making Bartender a required dependency of your addon.
  Reply With Quote
12-14-10, 06:13 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Could you be more specific about "doesn't work"? Does your code trigger a Lua error message? What do you expect to happen? What exactly does happen?

Without knowing anything else, I think you may be confused about what SetParent does. It sets the frame's parent, yes, but that has nothing to do with a frame's position, so you shouldn't expect to see any immediate visual change when you reparent a frame. I'm guessing you're trying to do something like this:

pet:SetPoint("BOTTOM", BT4PetButton1, "TOP", 0, 20)
  Reply With Quote
12-14-10, 06:04 PM   #6
barbol12
A Cyclonian
 
barbol12's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 42
[quote]
Originally Posted by Phanx View Post
Could you be more specific about "doesn't work"? Does your code trigger a Lua error message? What do you expect to happen? What exactly does happen?

Without knowing anything else, I think you may be confused about what SetParent does. It sets the frame's parent, yes, but that has nothing to do with a frame's position, so you shouldn't expect to see any immediate visual change when you reparent a frame. I'm guessing you're trying to do something like this:

pet:SetPoint("BOTTOM", BT4PetButton1, "TOP", 0, 20)
no not at all... heres what i am doing....
local pet = CreateFrame("Frame", nil, UIParent)
pet:SetWidth(317)
pet:SetHeight(24)
pet:SetPoint("BOTTOM", 2, 150)
pet:SetFrameStrata("BACKGROUND")
pet:SetBackdrop({
bgFile = "Interface\\Addons\\textures\\panels.tga",
edgeFile = "Interface\\Addons\\textures\\Stripped.tga",
tile = "false",
tileSize = 1,
edgeSize = 12,
Insets = {left = 1, right = 1, top = 1, bottom = 1}
})
pet:SetBackdropColor(0.1,0.1,0.1,1)
pet:SetBackdropBorderColor(0.1,0.1,0.1,1)
pet:SetParent("BT4PetButton1")
as u can see it has its own position already.. all i am trying to do is get it to only show up, when the pet bar( or the bartender4 pet button 1, in most cases) shows up... and when i have no pet, or no bt4 pet button1 available it is disappeared... im just trying to figure why this isnt working..

when i set
pet:SetParent("BT4PetButton1")
into the table for the frame.. i lose the custom colorings on all my other frames.. and lose a few of them.... but when i take that line away, everything is fine again.
  Reply With Quote
12-14-10, 06:13 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Why aren't you just doing this?
Code:
local pet = CreateFrame("Frame", nil, BT4PetButton1)
3rd argument to CreateFrame is parent.


Also,
Code:
pet:SetParent("BT4PetButton1") -- string
is not the same as
Code:
pet:SetParent(BT4PetButton1) -- reference to frame

/edit: in the future, use a [code] block instead of a [quote] block to preserve formatting.
__________________
"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
12-14-10, 06:36 PM   #8
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Even better, use the [highlight=lua] tag so it colors everything automatically.

lua Code:
  1. local pet = CreateFrame("Frame", nil, UIParent)
  2. pet:SetWidth(317)
  3. pet:SetHeight(24)
  4. pet:SetPoint("BOTTOM", 2, 150)
  5. pet:SetFrameStrata("BACKGROUND")
  6. pet:SetBackdrop({
  7.     bgFile = "Interface\\Addons\\textures\\panels.tga",
  8.     edgeFile = "Interface\\Addons\\textures\\Stripped.tga",
  9.     tile = "false",
  10.     tileSize = 1,
  11.     edgeSize = 12,
  12.     Insets = {left = 1, right = 1, top = 1, bottom = 1}
  13.     })
  14. pet:SetBackdropColor(0.1,0.1,0.1,1)
  15. pet:SetBackdropBorderColor(0.1,0.1,0.1,1)
  16. pet:SetParent("BT4PetButton1")

Anyways, try setting your parent first, then the points. It's also a good practice to clear the points before reanchoring just to be safe (frame:ClearAllPoints())
  Reply With Quote
12-14-10, 09:45 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by barbol12 View Post
when i set into the table for the frame.. i lose the custom colorings on all my other frames.. and lose a few of them.... but when i take that line away, everything is fine again.
That's because setting the parent resets a number of properties. You should be doing what Seerah already suggested, and including the parent in your CreateFrame call. At the very least, move your SetParent line to be directly after the CreateFrame line, before you set any of the frame's other properties.

Originally Posted by Seerah View Post
Also,
Code:
pet:SetParent("BT4PetButton1") -- string
is not the same as
Code:
pet:SetParent(BT4PetButton1) -- reference to frame
Actually, it is exactly the same. It just delays the global lookup until Blizzard's code, instead of doing it in your addon code.
  Reply With Quote
12-15-10, 10:14 AM   #10
barbol12
A Cyclonian
 
barbol12's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 42
well i got it to work for my pet bar... ended up switching addons to dominos.. and it worked fine.. but now i cant get it to parent to my class/stance bar...
here is the in-game name given for it...
DominosClassButton1
i ended up parenting my stance frame to that button... but it doesn't change.. still acts as though its parenting to the UIParent.

here is the coding for my frame.
Code:
local stance = CreateFrame("Frame", nil, DominosClassButton1)	
		stance:SetWidth(300)
		stance:SetHeight(43)
		stance:SetPoint("LEFT", 0, 0)
		stance:SetFrameStrata("BACKGROUND")
		stance:SetBackdrop({
			bgFile = "Interface\\Addons\\textures\\panels.tga",
			edgeFile = "Interface\\Addons\\textures\\Stripped.tga",
			tile = "false",
			tileSize = 1,
			edgeSize = 15,
			Insets = {left = 1, right = 1, top = 1, bottom = 1}
			})
		stance:SetBackdropColor(0.1,0.1,0.1,1)
		stance:SetBackdropBorderColor(0.1,0.1,0.1,1)
so what is going wrong??
  Reply With Quote
12-16-10, 04:24 AM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
To test something, try putting this above the CreateFrame() call.
Code:
print(DominosClassButton1)
It'll cause something to show up in the chat frame.
If it says "nil", the pointer doesn't exist at that specific time.
If it says "table: <some hex value>", that should be the frame you're trying to set your parent as.
__________________
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)
  Reply With Quote
12-16-10, 07:27 AM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by barbol12 View Post
so what is going wrong??
Without seeing your whole code (and your TOC) I couldn't say for sure, but the most likely possibility is that Dominos hasn't yet created that frame at the time your code runs.
  Reply With Quote
12-16-10, 02:10 PM   #13
barbol12
A Cyclonian
 
barbol12's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 42
Originally Posted by Phanx View Post
Without seeing your whole code (and your TOC) I couldn't say for sure, but the most likely possibility is that Dominos hasn't yet created that frame at the time your code runs.
TOC:
## Interface: 40000
## Version: 4.0
## Title: BarbolUI
## Author: Barbol12
## Notes: User Interface Modification
## Dependencies: Dominos

BarbolUI.xml
and my whole code.. is just all frames.. but here is the stance frame that is being used.
lua Code:
  1. local stance = CreateFrame("Frame", nil, DominosClassButton1)  
  2.         stance:SetWidth(300)
  3.         stance:SetHeight(43)
  4.         stance:SetPoint("LEFT", 0, 0)
  5.         stance:SetFrameStrata("BACKGROUND")
  6.         stance:SetBackdrop({
  7.             bgFile = "Interface\\Addons\\textures\\panels.tga",
  8.             edgeFile = "Interface\\Addons\\textures\\Stripped.tga",
  9.             tile = "false",
  10.             tileSize = 1,
  11.             edgeSize = 15,
  12.             Insets = {left = 1, right = 1, top = 1, bottom = 1}
  13.             })
  14.         stance:SetBackdropColor(0.1,0.1,0.1,1)
  15.         stance:SetBackdropBorderColor(0.1,0.1,0.1,1)

i set my TOC file to have a dependency to Dominos for my addon... but it doesn't change it.. still acts as though the dependency isnt there... plus it worked fine for the PetActionButton... and i didnt have dominos as a dependancy then.
  Reply With Quote
12-16-10, 02:32 PM   #14
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
Just because you have set a dependency does not mean that that dependency has created all it's frames when your addon is loaded.
Dominos may wait until certain events occur in game (e.g. PLAYER_ENTERING_WORLD) before it creates some of its frames.


In fact, looking through the Dominos code I can see that the DominosClassButton1 you are trying to use as a parent is not created until the event UPDATE_SHAPESHIFT_FORMS is fired.

You have to use some strategy to create your frames after Dominos haves created its frames.
  Reply With Quote
12-16-10, 09:31 PM   #15
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by barbol12 View Post
plus it worked fine for the PetActionButton... and i didnt have dominos as a dependancy then.
That's because PetActionButton is part of the default UI, which loads before addons, and is created immediately when the relevant code loads.

By contrast, most addons try to avoid creating frames that may not be needed until they are actually needed. What you're seeing in Dominos is a good example of this -- rather than creating stance/form buttons as soon as it loads, the addon waits until those buttons are actually needed, and then creates them on demand. This way, if you're playing a mage, the addon isn't wasting resources by creating a bunch of frames you'll never see or use.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » parent 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