Thread Tools Display Modes
Prev Previous Post   Next Post Next
07-07-16, 04:13 PM   #1
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
Slider issues

Searching on the web I read the template "FauxScrollFrameTemplate" is now obsolete, you confirm? I have followed the advice of this page. But now I have two problems:
  • How do I put the slider into the frame? In this picture appears outside of him?
  • Because the method
    Lua Code:
    1. Slider:Disable()
    does not work?

Here is the code:

Lua Code:
  1. --parent frame
  2. local frame = CreateFrame("Frame", "MyFrame", UIParent)
  3. frame:SetSize(200, 320)
  4. frame:SetPoint("CENTER")
  5. local texture = frame:CreateTexture()
  6. texture:SetAllPoints()
  7. texture:SetTexture(1,1,1,1)
  8. frame.background = texture
  9.  
  10. --scrollframe
  11. scrollframe = CreateFrame("ScrollFrame", nil, frame)
  12. scrollframe:SetPoint("TOPLEFT", 6, -8)
  13. scrollframe:SetPoint("BOTTOMRIGHT", -30, 8)
  14. scrollframe:EnableMouse(true)
  15. scrollframe:EnableMouseWheel(true)
  16. local texture = scrollframe:CreateTexture()
  17. texture:SetAllPoints()
  18. frame.scrollframe = scrollframe
  19.  
  20. --scrollbar
  21. scrollbar = CreateFrame("Slider", nil, scrollframe, "UIPanelScrollBarTemplate")
  22. scrollbar:SetPoint("TOPLEFT", frame, "TOPRIGHT", 6, -16)
  23. scrollbar:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT", 6, 16)
  24. scrollbar:SetMinMaxValues(0, 320)
  25. scrollbar:SetValueStep(16)
  26. scrollbar.scrollStep = 16
  27. scrollbar:SetValue(0)
  28. scrollbar:SetWidth(29)
  29. scrollbar:EnableMouse(true)
  30. scrollbar:EnableMouseWheel(true)
  31. scrollframe.ScrollBar = scrollbar
  32. scrollbar:SetScript("OnValueChanged",
  33. function (self, value)
  34. self:GetParent():SetVerticalScroll(value)
  35. end)
  36. scrollbar:SetScript("OnMouseWheel", function(self, delta)
  37.       delta = ((delta * scrollbar:GetValueStep())) * -1
  38.       local value = scrollbar:GetValue()
  39.       scrollbar:SetValue(value + delta)
  40.       if ((value + delta) > 0) then self:GetParent():SetVerticalScroll(value + delta) end
  41. end)
  42. local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
  43. scrollbg:SetAllPoints(scrollbar)
  44.  
  45. frame.scrollbar = scrollbar
  46. scrollbar:EnableMouse(false)
  47. scrollframe:SetScript("OnMouseWheel", function(self, delta)
  48.       delta = ((delta * scrollbar:GetValueStep())) * -1
  49.       local value = scrollbar:GetValue()
  50.       scrollbar:SetValue(value + delta)
  51.       if ((value + delta) > 0) then self:SetVerticalScroll(value + delta) end
  52. end)
  53.  
  54.  
  55. --content frame
  56. local content = CreateFrame("Button", nil, scrollframe)
  57. content:SetSize(128, 16)
  58. local texture = content:CreateTexture()
  59. texture:SetAllPoints()
  60. texture:SetTexture(1,0,0,1)
  61. local text = content:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
  62. text:SetPoint("CENTER", content)
  63. content.text = text
  64. text:SetText("content")
  65. scrollframe.content = content
  66.  
  67. scrollframe:SetScrollChild(content)
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Slider issues


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