Quantcast
WoWInterface - View Single Post - Issue with ScrollFrame and Tooltips
View Single Post
08-21-17, 11:36 AM   #1
maqjav
A Cyclonian
Join Date: Feb 2012
Posts: 49
Issue with ScrollFrame and Tooltips

Hello.

I have a main frame that contains a scrollFrame. This scrollFrame has an inner frame that contains a list of frames inside, and each of these children have a tooltip.

Everything is working fine, however I can see the tooltips of the children frames that aren't visible in that moment and are hidden out of my mainFrame.

Code:
local mainFrame = CreateFrame("Frame", "mainFrame ", UIParent, "UIPanelDialogTemplate") 
mainFrame:SetSize(1000, 600)
mainFrame:SetPoint("CENTER")
mainFrame:SetMovable(true)
mainFrame:EnableMouse(true)
mainFrame.Title:SetText("Example")
mainFrame:RegisterForDrag("LeftButton")
mainFrame:SetScript("OnDragStart", mainFrame.StartMoving)
mainFrame:SetScript("OnDragStop", mainFrame.StopMovingOrSizing)

local scrollFrame = _G.CreateFrame("ScrollFrame", "scrollFrame", mainFrame)
scrollFrame:SetPoint("TOPLEFT", 8, -26)
scrollFrame:SetPoint("BOTTOMRIGHT", mainFrame, "BOTTOMLEFT", 400, 10)
scrollFrame:EnableMouseWheel(true)

scrollFrame.scrollbar = CreateFrame("Slider", nil, scrollFrame, "UIPanelScrollBarTemplate") 
scrollFrame.scrollbar:SetPoint("TOPLEFT", scrollFrame, "TOPRIGHT", -1, -16) 
scrollFrame.scrollbar:SetPoint("BOTTOMLEFT", scrollFrame, "BOTTOMRIGHT", -1, 15) 
scrollFrame.scrollbar:SetValueStep(SCROLL_STEP_VALUE) 
scrollFrame.scrollbar.scrollStep = SCROLL_STEP_VALUE
scrollFrame.scrollbar:SetValue(1) 
scrollFrame.scrollbar:SetWidth(SLIDERUI_WIDTH)

local innerFrame = CreateFrame("Frame", "innerFrame", scrollFrame) 
innerFrame:SetSize(400, 3000)
innerFrame:SetPoint("TOPLEFT", 0, 0)
scrollFrame:SetScrollChild(innerFrame);

for i, element in ipairs(myElementList) do
        local childFrame = _G.CreateFrame("Button", "elementFrame"..i, innerFrame, "SecureActionButtonTemplate")
	childFrame:SetSize(400, 50)
	childFrame:SetPoint("TOP", 0, -(50 * (i - 1)))
        childFrame:SetScript("OnEnter", function(self) 
              local tooltip = LibStub('LibQTip-1.0'):Acquire("MyExampleToolTip", 1, "LEFT")
              self.tooltip = tooltip
              tooltip:AddLine(element)
              tooltip:SmartAnchorTo(self)
              tooltip:Show()
        end)
        childFrame:SetScript("OnLeave", function(self) 
              LibStub('LibQTip-1.0'):Release(self.tooltip)
        end)
end
As you can see with this code my mainFrame height is 600, the innerFrame height is 3000. If I scroll down to 1500, moving the mouse above or under my mainFrame, I see the tooltips, which means that the OnEnter event is being fired even if I cannot see the children frames.

How can I fix this?

Thanks.

Last edited by maqjav : 08-21-17 at 11:42 AM.
  Reply With Quote