WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Slider issues (https://www.wowinterface.com/forums/showthread.php?t=53852)

Benalish 07-07-16 04:13 PM

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)

Ketho 07-07-16 05:16 PM

Quote:

Originally Posted by Benalish (Post 316247)
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

Resike 07-07-16 06:40 PM

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)

Lombra 07-08-16 04:31 AM

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?

Benalish 07-08-16 02:30 PM

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

Ketho 07-08-16 04:53 PM

Quote:

Originally Posted by Benalish (Post 316274)
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


All times are GMT -6. The time now is 10:30 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI