Thread Tools Display Modes
09-21-09, 10:14 AM   #1
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Target of Target select helper frame

I'm trying to create a frame that, if clicked, selects the Target of Target. I'm currently using this to create the frame:

Code:
		local ToTSelectHelper = CreateFrame("Frame","ToTSelectHelper",self)
		ToTSelectHelper:SetWidth(80)
		ToTSelectHelper:SetHeight(20)
		ToTSelectHelper:SetPoint("TOPLEFT", self, "TOPRIGHT", 0, -30)
		ToTSelectHelper:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }})
(the backdrop is just there for config purposes to make the frame visible)

The question is: How do I make this interactive/clickable. And I guess after it is clickable, it still needs to "know" what it should do when clicked?
  Reply With Quote
09-21-09, 11:44 AM   #2
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
Minimum stuff you need:

Code:
	self:EnableMouse(true)
	self:RegisterForClicks"AnyDown"
After that, you need just need an OnClick script.

Silly question, why not just have oUF spawn a ToT frame?

edit: One thing I forgot, the frame needs to be a Button to be able to be clicked.

Last edited by wurmfood : 09-21-09 at 11:47 AM.
  Reply With Quote
09-21-09, 01:49 PM   #3
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I have a ToT frame spawned (take a look at oUF_viv). But you can't click/select it very well, due to the way it's set up (behind the target frame). Because of that, I want ToT's name to be clickable to select the ToT, easily. I don't know if it's easier or possible to make the name font string clickable or just add a frame there that is parented to ToT and in the same area like the name.
  Reply With Quote
09-21-09, 02:13 PM   #4
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
If it's not important for the health bar to be clickable (since it's behind your target frame), just make your TOT frame the size of your font string, anchor the font string to the center of the frame, and anchor the frame to where the font string is currently. Then instead of creating your health bar on the frame itself, just anchor it to the target frame.

That explanation couldn't really get any more confusing. If you need it clarified anymore I can give a short snippet.
  Reply With Quote
09-21-09, 02:19 PM   #5
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
Ah, I see. Well, this might work.

Create a button frame attached to your ToT frame. Set the size and location to where you have the ToT name string and then set the alpha to 0. Set the OnClick to ToT's OnClick.

Something like this:
Code:
self.NameButton = self:CreateFrame("Button", nil, self)
self.NameButton:SetAllPoints(self.Name)
self.NameButton:EnableMouse(true)
self.Namebutton:RegisterForclicks"AnyUp"
self.NameButton:SetScript("OnClick", self:GetScript("OnClick"))
Code is untested, but it might be a good place to start. Honestly, I'm not sure if setting the enable mouse, register for clicks, or the set script is completely needed.
  Reply With Quote
09-21-09, 02:34 PM   #6
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I'll try this, thanks.

@Waverian
I know, but I want to avoid messing around with frame width and height, if possible. So this option will be more like "if I have no other option". Thanks though.
  Reply With Quote
09-21-09, 02:47 PM   #7
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Code:
self.ToT = CreateFrame('Button', nil, self, 'SecureUnitButtonTemplate')
self.ToT:SetWidth(100)
self.ToT:SetHeight(200)
self.ToT:SetPoint('LEFT', self, 'RIGHT')
self.ToT:SetAttribute('type', 'target')
self.ToT:SetAttribute('unit', 'targettarget')
-- this hides our clicky frame if the unit doesn't exist
RegisterUnitWatch(self.ToT, false)

change height width point etc obviously~.
  Reply With Quote
09-21-09, 02:51 PM   #8
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by Waverian View Post
Code:
self.ToT = CreateFrame('Button', nil, self, 'SecureUnitButtonTemplate')
self.ToT:SetWidth(100)
self.ToT:SetHeight(200)
self.ToT:SetPoint('LEFT', self, 'RIGHT')
self.ToT:SetAttribute('type', 'target')
self.ToT:SetAttribute('unit', 'targettarget')
-- this hides our clicky frame if the unit doesn't exist
RegisterUnitWatch(self.ToT, false)

change height width point etc obviously~.
Pure win, thanks a lot! <3
  Reply With Quote
09-21-09, 04:15 PM   #9
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
Much better option.

Not having to worry about the height/width stuff is part of why I suggested the SetAllPoints. Takes care of all of that quickly and easily.
  Reply With Quote
09-21-09, 05:05 PM   #10
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
I haven't confirmed but I'm pretty sure SetAllPoints won't function properly unless you explicitly set a height / width for the fontstring (which is pretty rare to do since it's not necessary).
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Target of Target select helper 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