I cannot figure out why the scrolling bar starts at the bottom plus if look in the picture the bottom button is enabled and the top is not enabled.
I can drag the scroll bar to the top and then the top button becomes enabled and the bottom is not what I am I doing wrong.
Here is my code
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.blizzard.com/wow/ui/FrameXML/UI.xsd">
<Button name="MacroIconTest_IconTemplate" virtual="true">
<Size x="34" y="24" />
<NormalTexture name="$parentIcon" setAllPoints="true" />
<HighlightTexture alphaMode="ADD"
file="Interface\Buttons\ButtonHilight-Square" />
<Scripts>
<OnLoad>
self:RegisterForClicks("LeftButtonUp")
self:RegisterForDrag("LeftButton")
</OnLoad>
<OnReceiveDrag>
CDB.UpdateList()
</OnReceiveDrag>
</Scripts>
</Button>
<Frame name="CDBOptionPanel">
<Frames>
<Button name="$parentIcon1" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT">
<Offset x="10" y="-36" />
</Anchor>
</Anchors>
</Button>
<Button name="$parentIcon2" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentIcon1" />
</Anchors>
</Button>
<Button name="$parentIcon3" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentIcon2" />
</Anchors>
</Button>
<Button name="$parentIcon4" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentIcon3" />
</Anchors>
</Button>
<Button name="$parentIcon5" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentIcon4" />
</Anchors>
</Button>
<Button name="$parentIcon6" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT"
relativeTo="$parentIcon1" />
</Anchors>
</Button>
<Button name="$parentIcon7" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentIcon6" />
</Anchors>
</Button>
<Button name="$parentIcon8" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentIcon7" />
</Anchors>
</Button>
<Button name="$parentIcon9" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentIcon8" />
</Anchors>
</Button>
<Button name="$parentIcon10" inherits="MacroIconTest_IconTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentIcon9" />
</Anchors>
</Button>
<ScrollFrame name="$parentListScrollFrame" inherits="FauxScrollFrameTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentIcon1" relativePoint="TOPLEFT" />
<Anchor point="BOTTOMRIGHT" relativeTo="$parentIcon10" relativePoint="BOTTOMRIGHT"> <Offset x="-5" y="0" /></Anchor>
</Anchors>
<Scripts>
<OnVerticalScroll>
FauxScrollFrame_OnVerticalScroll(self, offset, 24, CDB.UpdateList)
</OnVerticalScroll>
<OnShow>
CDB.UpdateList()
</OnShow>
</Scripts>
</ScrollFrame>
</Frames>
<Scripts>
<OnLoad>
CDB_OnLoad(self)
</OnLoad>
</Scripts>
</Frame>
</Ui>
Code:
CDB = {}
spellList ={}
function CDB_OnLoad(panel)
panel.name = select(2, GetAddOnInfo("CDB"))
InterfaceOptions_AddCategory(panel)
end
function CDB.UpdateList()
local name = "CDBOptionPanelIcon"
if CursorHasItem() or CursorHasSpell() then
local linktype, info1, info2 = GetCursorInfo()
local watchtype, watchname, options
if linktype=='spell' then
watchtype, watchname = 'spell', (GetSpellName(info1, BOOKTYPE_SPELL))
_, _, icon = GetSpellInfo(watchname)
end
table.insert(spellList, icon)
ClearCursor()
end
local texture
for line= 1,10 do
lineplusoffset = line + FauxScrollFrame_GetOffset(CDBOptionPanelListScrollFrame) * 5;
if spellList[lineplusoffset] ~= nil then
texture = spellList[lineplusoffset]
else
texture = "Interface\\QuestFrame\\UI-QuestTitleHighlight"
end
local button = getglobal(name .. line)
button:SetNormalTexture(texture)
end
FauxScrollFrame_Update(CDBOptionPanelListScrollFrame,4,2,24);
end