Thread Tools Display Modes
11-18-10, 09:22 AM   #1
gorillaz09
A Murloc Raider
Join Date: Nov 2010
Posts: 8
Help with scrollingframe

I'm having a hard time understanding how the scrollframe works, I've finally managed to put together someting that looks like a scrollframe, I have my scrollchild (f) and my scrollframe but it won't scroll, what did I miss?

Code:
local tbl = {
   [2393] = "hello",
   [3293] = "hey",
   [3393] = "blabla",
   [12942] = "new",
   [21541] = "new",
   [21542] = "new",
   [21543] = "new",
   [21544] = "new",
   [11431] = "new",
   [11433] = "new",
   [11434] = "new",
   [11435] = "new",
}

SFrame = CreateFrame("SCROLLFRAME", "SFrame", UIParent, "UIPanelScrollFrameTemplate");
SFrame:SetPoint("LEFT", UIParent)
SFrame:SetWidth(160);
SFrame:SetHeight(100);
SFrame:SetHorizontalScroll(0)
SFrame:SetVerticalScroll(0)
SFrame:Show();
SFrame:SetBackdrop( {
      bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
      edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
      tile = true, tileSize = 16, edgeSize = 16,
      insets = { left = 5, right = 5, top = 5, bottom = 5 }
})
SFrame:SetBackdropColor(0, 0, 0, 0.5)
SFrame:SetBackdropBorderColor(1, 1, 1, 1)

local f=CreateFrame("ScrollingMessageFrame","crap",SFrame)
f:SetWidth(160)
f:SetHeight(120)
f:SetFontObject("GameFontNormal")
f:SetJustifyH("LEFT")
f:SetJustifyV("TOP")
f:SetScript("OnHyperlinkClick", function(self, linkData, link, button) 
      if IsShiftKeyDown() then
         ChatEdit_InsertLink(link)
      else
         ChatFrame_OnHyperlinkShow(linkData, link, button) 
      end
end)
f:SetSpacing(0)
f:SetMaxLines(10)
f:SetFading(false)
SFrame:SetScrollChild(f)

local function AddLinks()
   local text = ""
   
   for k, v in pairs(tbl) do
      print(k)
      text = text .. GetSpellLink(k).."\n"
   end
   f:AddMessage(text)
end
AddLinks()
  Reply With Quote
11-18-10, 09:50 AM   #2
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
ScrollingMessageFrames don't change size when you add content to them. They have built-in scrolling and don't require ScrollFrame parents. You should be able to make something like the default chat frames using just a ScrollingMessageFrame. If you need a scroll bar, you could probably rig one up using :SetScrollOffset, :GetCurrentScroll, :GetNumMessages, and :GetNumLinesDisplayed.
  Reply With Quote
11-18-10, 09:50 AM   #3
Dorwido
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 54
You need a scrollbar handler, you may wanna take a look at this tutorial:

http://www.wowwiki.com/Making_a_scro...lFrameTemplate
  Reply With Quote
11-19-10, 07:33 AM   #4
gorillaz09
A Murloc Raider
Join Date: Nov 2010
Posts: 8
thx guys

.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with scrollingframe


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