Thread Tools Display Modes
11-02-16, 05:50 AM   #1
Zavian
A Deviate Faerie Dragon
 
Zavian's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 10
Issues with my scrollframes since 7.1

Hello, I'm the developer of PileSeller and since some months the code remained untouched.
With the release of 7.1, though, after updating the TOC I noticed a very strange behavior from my scrollframes, in particular the items within it.
To make things simple, my addon is an autoseller that manages the drops you get from raids, instances and so on. These drops are saved into an array which is displayed as a list into a scrollframe (http://i.imgur.com/zPxQCw9.png)
All the items withing the list are interactable, so if you mouse over 'em you get a tooltip of the item, and if you click on 'em you can gather more informations from the item itself. The problem now, it's that the items that are not "rendered" (so they are in the non-visible part of the scrollframe) are interactable, while before 7.1 this was not the case (http://i.imgur.com/Cccg9kY.png). The code of the creation of these items is below.

Code:
function PileSeller:CreateScroll(parent, name, width, height, noBorder, noBackground)
	local f = CreateFrame("ScrollFrame", name, parent, "UIPanelScrollFrameTemplate")
	f:SetSize(width, height)
	f:SetClampedToScreen(true)
	f:EnableMouseWheel(true)
	if not noBackground then
		local tex = f:CreateTexture(nil, "BACKGROUND")
		tex:SetTexture([[Interface\Buttons\WHITE8X8]])
		tex:SetVertexColor(.27,.27,.27,1)
		tex:SetAllPoints()
	end
	if not noBorder then
		f:SetBackdrop({
			edgeFile = [[Interface\Buttons\WHITE8X8]], 
			edgeSize = 1, 
			insets = {
				left = 1,
				right = 1,
				top = 1,
				bottom = 1
		  }
		})
		f:SetBackdropBorderColor(0, 0, 0)
	end

	f.content = CreateFrame("Frame", name .. "Content")
	f.content:SetSize(width, height)
	f:SetScrollChild(f.content)

	f:SetScript("OnMouseWheel", function(self, delta) 
		local vertical = f:GetVerticalScroll()
		local max = f:GetVerticalScrollRange()
		_G[name .. "ScrollBar"]:SetMinMaxValues(0, max)
		local move = 13 * -delta
		if vertical + move > 0 and vertical + move < max then
			f:SetVerticalScroll(vertical + move)
		elseif vertical + move > max then
			f:SetVerticalScroll(max)
		elseif vertical + move < 0 then 
			f:SetVerticalScroll(0)
		end
		_G[name .. "ScrollBar"]:SetValue(f:GetVerticalScroll())
	end)

	return f
end
Fullscreen reader: http://hastebin.com/barerineli.lua

Code:
--- Function to create a button while filling a list
--- input:
	--- parent 		= scrollframe to fill
	--- id 			= item id (-1 = nil)
	--- progress 	= normally the method it's run in a for loop, used to create space from one button and another
	--- height 		= height of a button
	--- [zoneName]	= used for creating the ignored zones
--- outbut: none
function PileSeller:CreateScrollButton(parent, id, progress, width, height, zoneName, sources)
	local name = parent:GetName() .. "Button" .. progress
	local text = ""
	local found = ""
	if not parent[name] then
		parent[name] = CreateFrame("Button", parent:GetName() .. "Button" .. progress, parent)
		parent[name].t = parent[name]:CreateFontString(nil, "OVERLAY", "GameFontNormal")
	else parent[name]:Show() end
	if id ~= -1 then
		if parent:GetName() == "PileSeller_ConfigFrame_SavedScrollContent" then
			if psItemsSavedFound[id] then found = " " .. checkIcon end
		end
		local n, l, q, _t, _t, _t, _t, _t, _t, _t, _t  = GetItemInfo(id)
		text = n

		-- select text color
		qualities = {}
		qualities[0] = { r = 0.615, g = 0.615, b = 0.615}
		qualities[1] = { r = 1, g = 1, b = 1}
		qualities[2] = { r = .118, g = 1, b = 0}
		qualities[3] = { r = 0, g = .439, b = 1}
		qualities[4] = { r = .639, g = .207, b = .933}
		qualities[5] = { r = 1, g = .501, b = 0}
		qualities[6] = { r = .901, g = .800, b = .501}
		if q >= 6 then q = qualities[6]
		else q = qualities[q] end
		parent[name].t:SetTextColor(q.r, q.g, q.b)

		parent[name]:SetScript("OnEnter", function()
			GameTooltip:SetOwner(parent[name], "ANCHOR_BOTTOMRIGHT", 0, parent[name]:GetHeight())
			GameTooltip:SetHyperlink(l)
			GameTooltip:Show()
		end)
		parent[name]:SetScript("OnLeave", function()
			GameTooltip:Hide()
		end)
		PileSeller:debugprint(parent:GetName())
		if parent:GetName() ~= "PileSeller_SellingBoxFrame_ScrollContent" then
			parent[name]:SetScript("OnClick", function()
				lastClicked = parent
				PileSeller:SetItemInfo(PileSeller.UIConfig.itemInfos.item, id)
				if IsShiftKeyDown() then
					ChatEdit_InsertLink(l)
				elseif IsControlKeyDown() then
					DressUpItemLink(l)
				end				
			end)
		else
			parent[name]:RegisterForClicks("AnyDown")
			parent[name]:SetScript("OnClick", function(self, button)
				if IsShiftKeyDown() then
					ChatEdit_InsertLink(l)
				elseif IsControlKeyDown() then
					DressUpItemLink(l)
				end
				if button == "RightButton" then
					PileSeller:debugprint("banana")
					PileSeller:removeItem(l, psItems, parent)
					_G["PileSeller_SellingBoxFrame"]:Hide()
					_G["PileSeller_SellingBoxFrame"]:Show()
				end
			end)
		end
	elseif id == -1 then
		text = zoneName
		if parent:GetName() ~= "PileSeller_ConfigFrame_ItemInfos_MiniDialog_ScrollFrameContent" then			
			parent[name]:SetScript("OnClick", function()
				PileSeller.UIConfig.txtAddIgnoreZone:SetText(text)
			end)
		else
			if text == TRANSMOG_SOURCE_1 then
				parent[name]:SetScript("OnEnter", function()
					PileSeller:CreateTooltipInfo(parent[name], sources)
				end)
				parent[name]:SetScript("OnLeave", function() GameTooltip:Hide() end)
			end
		end
	end

	parent[name].t:SetText(text .. found)
	parent[name].t:SetPoint("LEFT", parent[name])
	parent[name].t:SetSize(width, height)
	parent[name]:SetSize(width, height)

	parent[name]:SetHighlightTexture("Interface\\AddOns\\PileSeller\\media\\highlight", "ADD")

	parent[name]:SetBackdrop({
		bgFile = [[Interface\Buttons\WHITE8X8]], 
	})
	if progress % 2 == 0 or progress == 0 then parent[name]:SetBackdropColor(.15, .15, .15,1)
	else parent[name]:SetBackdropColor(.27, .27, .27,1) end
	if progress == 1 then parent[name]:SetPoint("TOPLEFT", parent, 1, -1)
	else parent[name]:SetPoint("TOPLEFT", parent, 1, -height * (progress - 1) - 1) end

end
Fullscreen reader: http://hastebin.com/ofabamabak.lua

Did something change with these APIs in 7.1 or am I missing something?
To make some context, the first function it's used whenever the UI it's loaded for the first time, the second one it's used whenever I'm filling these lists.
__________________
Developer of PileSeller

Last edited by Zavian : 11-02-16 at 05:57 AM.
  Reply With Quote
11-02-16, 07:14 AM   #2
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
This was solved over on this thread.
Originally Posted by MunkDev View Post
Not sure if I'm providing any new information here, but I encountered this as well. The issue was of course the change to scroll frames, as they will not clip their children automatically unless defined either in XML or lua. To solve this, I simply put this in my scroll frame wrapper:
Lua Code:
  1. frame:SetClipsChildren(true)

In XML, the tag is clipChildren="true". This causes any children outside the boundaries of the frame to be unclickable and frankly not drawn at all. Any scroll frame now also returns an object type of plain "Frame", suggesting that the specific "ScrollFrame" widget doesn't exist anymore and is now an intrinsic frame template that simply provides scrolling and child anchoring methods.
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote
11-02-16, 08:14 AM   #3
Zavian
A Deviate Faerie Dragon
 
Zavian's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 10
Thank you, I must be blind for not seeing the topic.
__________________
Developer of PileSeller
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Issues with my scrollframes since 7.1


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