Quantcast

Hide the tooltip when a plugin is clicked

James Whitehead II [03-11-10 - 17:40]
Hide the tooltip when a plugin is clicked
Filename
NinjaPanel.lua
diff --git a/NinjaPanel.lua b/NinjaPanel.lua
index b87231b..722e2d1 100644
--- a/NinjaPanel.lua
+++ b/NinjaPanel.lua
@@ -65,6 +65,7 @@ end)
 -- Local functions that are defined below
 local SortWeightName
 local Button_OnEnter, Button_OnLeave
+local Button_OnMouseDown
 local Button_OnDragStart, Button_OnDragStop, Button_OnUpdateDragging
 local Button_Tooltip_OnEnter, Button_Tooltip_OnLeave
 local Panel_UpdateLayout
@@ -451,6 +452,7 @@ function Panel_UpdateLayout(self)
 		NinjaPanel:UpdateTooltipHandlers(button, entry.object)

 		button:SetScript("OnClick", entry.object.OnClick)
+        button:SetScript("OnMouseDown", Button_OnMouseDown)
 		button:SetScript("OnDragStart", Button_OnDragStart)
 		button:SetScript("OnDragStop", Button_OnDragStop)
 		button:RegisterForDrag("LeftButton")
@@ -513,6 +515,13 @@ function SortWeightName(a,b)
 	end
 end

+function Button_OnMouseDown(self, ...)
+    if self.tooltip_shown then
+        GameTooltip:Hide()
+        self.tooltip_shown = false;
+    end
+end
+
 function Button_OnEnter(self, ...)
 	GameTooltip:SetOwner(self, "ANCHOR_NONE")
 	GameTooltip:SetPoint("TOPLEFT", self, "BOTTOMLEFT")
@@ -523,6 +532,7 @@ function Button_OnEnter(self, ...)
 		GameTooltip:SetText(self.entry.name)
 	end
 	GameTooltip:Show()
+    self.tooltip_shown = true
 end

 function Button_OnLeave(self, ...)