Thanks Phanx and Seerah for answers.
I have checked the Phanx code and it works nicely (the 2nd bigger one) but I think I'll leave the button as they are now, because it doesn't work with all buttons templates or with no template at all.
Btw finally I understood how it works. As usual it was a little bit more complicated then I thought :-)
Ok. In the meantime I have solved also the question nr.3 I asked:
3) Is possible to have the scrollframe "bordered" like the input box below ?
|
I checked the rtest by Zork (thanks) and I have discovered the Templates world :-)
Now I am investigating why the scrollframe works nicely in the test addon I make following the Lombra suggestion/code posted at the beginning of this thread, while it have the problem I have pointed out with the picture when I build the scrollist array from my data.
If I used something like:
Lua Code:
RemGankLS = { "qui", "quo", "qua", etc etc }
It works as expected and I don't have the iussue shown in the picture.
But I have a table in this way saved:
Lua Code:
RemGankDB = {
["qui"] = {
["name"] = "qui",
["date"] = "06.01.2013 19:28:24",
["desc"] = "generic ganker",
["lastloc"] = "Massiccio del Kun-Lai/Presidio del Fuoco Yongqi",
["nrkill"] = 1,
},
["quo"] = {
["name"] = "quo",
["date"] = "03.02.2013 17:35:10",
["desc"] = "generic ganker",
["lastloc"] = "Vallata dell'Eterna Primavera/Volta di Guo-Lai",
["nrkill"] = 1,
},
["qua"] = {
["name"] = "qua",
["date"] = "09.02.2013 10:57:16",
["desc"] = "generic ganker",
["lastloc"] = "Valle dei Quattro Venti/Mezzocolle",
["nrkill"] = 1,
},
--- etc etc
}
So to use a number reference to the records for the scrollframe I was not able to find a better solution of doing something like this:
Lua Code:
function RemGank_DB_Dump()
RemGankLS = {}
for name in pairs(RemGankDB) do
name = name:lower()
if RemGankDB[name]["name"] then
table.insert(RemGankLS, RemGankDB[name]["name"])
end
end
-- Sort the list alphabetically
table.sort(RemGankLS)
end
And everything works but the slider have the problem I show.
Someone have an idea on why it happens or if the problem is the dumping how to call this code :
Lua Code:
function RemGank_ListFrame_Update(self)
local numItems = #RemGankLS
FauxScrollFrame_Update(self, numItems, NUM_BUTTONS, BUTTON_HEIGHT)
local offset = FauxScrollFrame_GetOffset(self)
for line = 1, NUM_BUTTONS do
local lineplusoffset = line + offset
local button = buttons[line]
if lineplusoffset <= numItems then
button:SetText(RemGankLS[lineplusoffset])
button:Show()
else
button:Hide()
end
end
end
-- [...]
for i = 1, NUM_BUTTONS do
local button = CreateFrame("Button", nil, scrollFrame:GetParent(), "UIPanelButtonTemplate")
if i == 1 then
button:SetPoint("TOP", scrollFrame)
else
button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
end
button:SetNormalFontObject("GameFontNormal")
button:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
button:SetText(RemGankLS[i])
button:SetScript("OnClick", function(self)
RemGank_Input_eb2:SetText(button:GetText())
info_name:SetText(button:GetText())
info_desc:SetText(RemGankDB[button:GetText()]["desc"])
info_loc_title:SetText("Last Kill:")
info_date:SetText(RemGankDB[button:GetText()]["date"])
info_loc:SetText(RemGankDB[button:GetText()]["lastloc"])
info_kills_title:SetText("Tot.Kills:")
info_kills:SetText(RemGankDB[button:GetText()]["nrkill"])
end)
buttons[i] = button
end
without the need of dumping the first table RemGankDB (referenced by name) to RemGankLS (indexed by numbers) ?
Thanks for patience and sorry again about all these questions.