Quantcast
Slider issues - WoWInterface
 
Thread Tools Display Modes
07-07-16, 04:13 PM   #1
Benalish
A Theradrim Guardian
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 60
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
07-07-16, 05:16 PM   #2
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 942
Originally Posted by Benalish View Post
I have followed the advice of this page.

Can't really help you with your problem, but don't use WoWWiki, it's horribly outdated
But it's the same for Wowpedia in this case...

http://forums.wowace.com/showthread.php?t=20057
  Reply With Quote
07-07-16, 06:40 PM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,289
First FauxScrollFrameTemplate is still there even in Legion.

For your question all you need to do is to manipulte the x values of the SetPoints of the scroll bar:

Lua Code:
  1. scrollbar:SetPoint("TOPLEFT", frame, "TOPRIGHT", 6, -16)
  2. scrollbar:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT", 6, 16)
  Reply With Quote
07-08-16, 04:31 AM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Not saying you're wrong (because I'm not really keeping myself in the loop recently), but where did you read that FauxScrollFrameTemplate is obsolete?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
07-08-16, 02:30 PM   #5
Benalish
A Theradrim Guardian
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 60
This HOWTO describes how to create a list view using the [DEPRECATED http://wowprogramming.com/utils/xmlb...lTemplates.xml FauxScrollFrameTemplate] FrameXML class. An alternative is to simply create a Slider object of your own, but there is no HOWTO on that at the moment. Using CreateFrame() to create the list items dynamically may also be a good idea.

http://wowwiki.wikia.com/wiki/Making...lFrameTemplate
  Reply With Quote
07-08-16, 04:53 PM   #6
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 942
Originally Posted by Benalish View Post
This HOWTO describes how to create a list view using the [DEPRECATED http://wowprogramming.com/utils/xmlb...lTemplates.xml FauxScrollFrameTemplate] FrameXML class.

Again, don't use WoWWiki

The "DEPRECATED" in this case was referring to the wdnlink template, because wowprogramming.com doesn't have a FrameXML browser anymore
  Reply With Quote

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

Thread Tools
Display Modes

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