Quantcast Issue with ScrollFrame and Tooltips - WoWInterface
Thread Tools Display Modes
08-21-17, 11:36 AM   #1
maqjav
An Aku'mai Servant
Join Date: Feb 2012
Posts: 38
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
08-21-17, 12:02 PM   #2
maqjav
An Aku'mai Servant
Join Date: Feb 2012
Posts: 38
Found the solution here.

Adding this it's fixed:

Code:
scrollFrame:SetClipsChildren(true)
  Reply With Quote
08-22-17, 05:34 AM   #3
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 242
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.
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Issue with ScrollFrame and Tooltips

Thread Tools
Display Modes

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