WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Issue with ScrollFrame and Tooltips (https://www.wowinterface.com/forums/showthread.php?t=55664)

maqjav 08-21-17 11:36 AM

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.

maqjav 08-21-17 12:02 PM

Found the solution here.

Adding this it's fixed:

Code:

scrollFrame:SetClipsChildren(true)

Kkthnx 08-22-17 05:34 AM

Awesome find. I had a similar issue with my scroll frame and this has fixed it. Thank you kindly for sharing your fix. I mentioned your post in my commented fix in my code. :rolleyes:


All times are GMT -6. The time now is 02:56 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI