So for some reason my ItemScrollFrame doesn't clip my scroll child contents. It's supposed to be done by a single line of code
Code:
tab.ItemScrollFrame:SetScrollChild(tab.ItemScrollFrameChild)
but it doesn't. The green area in the screenshot is my scroll frame.
https://imgur.com/a/cyI4DfQ
I've created my buttons so all of them are parented to the scroll frame
Code:
local ButtonIndex = {}
local index = 1
local first_elem = true
for key, item in next, namespace.searchResult do
local buttonName = key .. "Button"
if first_elem then
tab.buttonName = CreateFrame("Button", buttonName, tab.ItemScrollFrame, "OptionsListButtonTemplate")
tab.buttonName:SetPoint("TOPLEFT", tab.ItemScrollFrameChild, "TOPLEFT", 4, -4)
tab.buttonName:SetSize(192, 10)
tab.buttonName:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2")
tab.buttonName:SetText(item.name)
if item.slot then
tab.buttonName.tooltipText = item.itemType .. ", " .. item.slot
else
tab.buttonName.tooltipText = item.itemType
end
tab.buttonName:SetScript("OnEnter", OnEnter)
tab.buttonName:SetScript("OnLeave", OnLeave)
tab.buttonName:SetScript("OnClick", OnClickItemFrameButton)
table.insert(ButtonIndex, buttonName)
index = index + 1
first_elem = false
else
tab.buttonName = CreateFrame("Button", buttonName, tab.ItemScrollFrame, "OptionsListButtonTemplate")
tab.buttonName:SetPoint("TOPLEFT", ButtonIndex[index - 1], "TOPLEFT", 0, -11)
tab.buttonName:SetSize(192, 10)
tab.buttonName:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2")
tab.buttonName:SetText(item.name)
if item.slot then
tab.buttonName.tooltipText = item.itemType .. ", " .. item.slot
else
tab.buttonName.tooltipText = item.itemType
end
tab.buttonName:SetScript("OnEnter", OnEnter)
tab.buttonName:SetScript("OnLeave", OnLeave)
tab.buttonName:SetScript("OnClick", OnClickItemFrameButton)
table.insert(ButtonIndex, buttonName)
index = index + 1
end
end
tab.ItemScrollFrameChild:SetSize(190, index * 11)