Thread Tools Display Modes
11-04-13, 03:28 PM   #1
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Question Can Kgpanels do that?

Hi all!!.

I have a big dude.

I dont know if Kgpanels can do that, for that reason I ask here:

Can Kgpanels detect when I mouseover another frame?.

Or an alternative, mix a panel with a frame, if I mouseover the frame, its like I mouseover both elements, the panel and the frame.

For example:

I have a panel with a code "x", and a Databroker.

when I mouseover the frame of the Databroker, the panel of Kgpanels react and for example change the color.

I explain what I need and why:

Since 4 days, now when I click the frame of StatBlock_Folks (Friends), appear a pop-up in the middle of the screen (the default, Blizzard bloked that addon action only avaliable for....).

I need a way that when I mouseover StatBlockCore_Folks_Friend or Friend frame of Blizz is open the text change the color.

I can do both with a kgpanel with that codes:

OnLoad:

Code:
local font,size = self.text:GetFont()
self.text:SetFont(font,size,"OUTLINE")
self.text:SetJustifyH("CENTER")
self.text:SetJustifyV("CENTER")

local _, class = UnitClass("player")
local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
self.text:SetTextColor(color.r, color.g, color.b)

self:RegisterEvent("PLAYER_LOGIN")
self:RegisterEvent("FRIENDLIST_UPDATE")
OnEvent:

Code:
local bnTotal, bnCount = BNGetNumFriends()
local fTotal, fCount = GetNumFriends()
local total = bnCount+fCount
self.text:SetText(string.format("Friends: |cffffffff%d/%d|r", fCount + bnCount, fTotal + bnTotal))
OnEnter:

Code:
self.entered = true
OnLeave:

Code:
self.entered = false
OnUpdate:

Code:
local bnTotal, bnCount = BNGetNumFriends()
local fTotal, fCount = GetNumFriends()
local total = bnCount+fCount

if self.entered or FriendsListFrame:IsShown() then

self.text:SetText(string.format("|cffffffffFriends:%d/%d|r", fCount + bnCount, fTotal + bnTotal))

else

self.text:SetText(string.format("Friends:|cffffffff%d/%d|r", fCount + bnCount, fTotal + bnTotal))

end
OnClick:

Code:
if pressed then

ToggleFriendsFrame()

end

So basically I remplace the par of the text of the broker with a panel of KgPanels, and fix both problems, now when I click the panel I hace 0 pop-ups, and when I mouseover the panel or open the friends frame, the text change the color.

So I need 2 ways to apply that:

1st: Put the panel behind the frame of StatBloclCore_Folks_Friends, remove the text of the broker, remove the function that toggle the friends frame (and cause problems), and detect when I mouseover the frame of DataBroker (for show the tooltip of the databroker, that works very good), and in the other hand make the efect of change the color on mouseover.

2nd: Mix both frames, remove the text of StatBloclCore_Folks_Friends and remove the function that toggle the friends frame (and cause problems), so when I mouseover or click the frame of StatBloclCore_Folks_Friends I do it in the frame of The broker, and in the panel of Kgpanels.

Sorry for the long post.

And thanks!!!
  Reply With Quote
11-05-13, 05:30 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Akatosh View Post
I have a big dude.
Just FYI, I don't think "dude" is the word you were looking for there.

Originally Posted by Akatosh View Post
Can Kgpanels detect when I mouseover another frame?
Only in the same way that anything can detect when the mouse enters or leaves a frame -- by setting OnEnter and OnLeave scripts on the frame itself. You can do this with kgPanels. Set the scripts in your panel's OnLoad script; I'd advise using HookScript instead of SetScript, so you don't overwrite any scripts that are already set:
Code:
OtherFrame:HookScript("OnEnter", function(this)
	-- Use "this" instead of the usual "self" naming,
	-- so your panel's "self" is still accessible.
	if this:IsMouseOver() then
		-- The mouse is really over the other frame. Set a flag:
		this.isMouseOver = true
		-- ... and trigger your panel's OnEnter too:
		self:GetScript("OnEnter")(self)
	end
end)

OtherFrame:HookScript("OnLeave", function(this)
	if this.isMouseOver then
		-- The mouse was really over the other frame. Unset the flag:
		this.isMouseOver = false
		-- ... and trigger your panel's OnLeave too:
		self:GetScript("OnLeave")(self)
	end
end)
Then, in your panel's OnEnter script, trigger the other frame's OnEnter script if the mouse is really over your panel:
Code:
-- Do your panel's actual mouseover stuff here.
-- Then check if you need to do anything with the other frame:
if self:IsMouseOver() then
	-- The mouse is really over the panel. Set a flag:
	self.isMouseOver = true
	-- ... and trigger the other frame's OnEnter too:
	OtherFrame:GetScript("OnEnter")(OtherFrame)
end
Do the same in your panel's OnLeave script:
Code:
-- Do your panel's actual mouseout stuff here.
-- Then check if you need to do anything with the other frame:
if self.isMouseOver then
	-- The mouse was really over the panel. Unset the flag:
	self.isMouseOver = false
	-- ... and trigger the other frame's OnLeave too:
	OtherFrame:GetScript("OnLeave")(OtherFrame)
end
Make sure your panel and the other frame are not actually overlapping, or you will likely end up getting stuck in an infinite loop.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 11-05-13 at 08:30 PM.
  Reply With Quote
11-05-13, 06:59 PM   #3
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Thanks for all works ok!!!.

Last edited by Akatosh : 11-05-13 at 07:23 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Can Kgpanels do that?


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