View Single Post
02-11-13, 12:25 PM   #8
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Thanks again for you replies.

I think I have added the Settext ...
I packed your code in a simple addon so we can test better.

The code is:

Lua Code:
  1. local NUM_BUTTONS = 8
  2. local BUTTON_HEIGHT = 20
  3.  
  4. local list = {"aaaa","bbbbb","cccccc","ddddddd","eeeeee","ffffff","gggggg","hhhhh"}
  5. local buttons = {}
  6.  
  7. local function update(self)
  8.     local numItems = #list
  9.     print ("DEBUG: nr. items " .. numItems)
  10.     FauxScrollFrame_Update(self, numItems, NUM_BUTTONS, BUTTON_HEIGHT)
  11.     local offset = FauxScrollFrame_GetOffset(self)
  12.     for line = 1, NUM_BUTTONS do
  13.         local lineplusoffset = line + offset
  14.         local button = buttons[line]
  15.         if lineplusoffset > numItems then
  16.             button:Hide()
  17.         else
  18.             button:SetText(list[lineplusoffset])
  19.             button:Show()
  20.         end
  21.     end
  22. end
  23.  
  24. local scrollFrame = CreateFrame("ScrollFrame", "MyFirstNotReallyScrollFrame", UIParent, "FauxScrollFrameTemplate")
  25. scrollFrame:SetScript("OnVerticalScroll", function(self, offset)
  26.     FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, update)
  27. end)
  28.  
  29. for i = 1, NUM_BUTTONS do
  30.     local button = CreateFrame("Button", nil, scrollFrame:GetParent())
  31.     if i == 1 then
  32.         button:SetPoint("TOP", scrollFrame)
  33.     else
  34.         button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
  35.     end
  36.     button:SetSize(96, BUTTON_HEIGHT)
  37.     button:SetText(list[i])
  38.     buttons[i] = button
  39. end
  40.  
  41. print ("DEBUG: Force updating")
  42. update(scrollFrame)

I attach also the zip file of the addon directory.

Thanks again.
Attached Files
File Type: zip MyModScrollBar.zip (1.1 KB, 514 views)
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote