-
Posted by Krafter on Wed, 06 May 2009 00:28:18
I have been trying to figure out how to use the slider widget in lua. I have not been able to find much info on this topic other than wowwiki. The example they give doesn't work at all. All I get is the min and max values stacked on top of ech other on a frame. Can someone please post an example or point me to a website that might help? This is what I tried from wowwili.
--local MySlider = CreateFrame('Slider', 'MySliderGlobalName', nil, 'OptionsSliderTemplate') MySlider:SetWidth(20) MySlider:SetHeight(100) MySlider:SetOrientation('VERTICAL') MySlider.tooltipText = 'This is the Tooltip hint' getglobal(MySlider:GetName() .. 'Low'):SetText('1'); getglobal(MySlider:GetName() .. 'High'):SetText('100'); getglobal(MySlider:GetName() .. 'Text'):SetText('5'); MySlider:Show()
-
Posted by jnwhiteh on Wed, 06 May 2009 06:42:51
I can't find this example on WowWiki so I don't have anything to compare it to. The problem you are experiencing is that you're trying to use a horizontal slider template on a vertical slider. This obviously won't work and the fact that the frame is 20 pixels wide is precisely why the low/high are appearing on top of each other.
Don't change the example and leave it horizontal and it should work properly. If you want a vertical slider you will need to find another template or create one of your own.
It's always best to start with EXACTLY the example listed and then alter it to your needs once you have it working.
-
Posted by Krafter on Wed, 06 May 2009 11:47:14
OMG! Am I that much of a noob? I didn't even see that. I will give it a shot as soon as I get home from work. LOL
-
Posted by Krafter on Wed, 06 May 2009 23:43:07
Well, I tried it and it still doesn't work for me. This is what I am seeing. I don't see anything that looks like a slider. And this is where I got it from. http://www.wowwiki.com/UIOBJECT_Slider
5 ------------------------------ | | | | | | | | | | | | | | | | | | ------------------------------ Low High 1 100 1 + Low and High + 100 is stacked.
local MySlider = CreateFrame('Slider', 'MySliderGlobalName', nil, 'OptionsSliderTemplate')
MySlider:SetWidth(200)
MySlider:SetHeight(200)
MySlider:SetPoint('TOPLEFT', 10, -10)
MySlider:SetOrientation('VERTICAL')
MySlider.tooltipText = 'This is the Tooltip hint'
getglobal(MySlider:GetName() .. 'Low'):SetText('1');
getglobal(MySlider:GetName() .. 'High'):SetText('100');
getglobal(MySlider:GetName() .. 'Text'):SetText('5');
MySlider:Show()
-
Posted by jnwhiteh on Thu, 07 May 2009 10:37:09
You are completely misunderstanding the purpose of templates.
- You cannot and should not just set the size on a frame that in inheriting from a template. In this case, the template already specifies a size, and you should respect that.
- You cannot and should not just assume you can change the orientation of a slider without having to change anything else. Especially considering I told you already that you cannot do that because the graphics do not support it. It's not as simple as just flipping an orientation flag.
This is the code to display a slider:
if not MySlider then CreateFrame('Slider', 'MySlider', UIParent, 'OptionsSliderTemplate') end MySlider:ClearAllPoints() MySlider:SetPoint("CENTER", UIParent, "CENTER", 0, 300) MySlider:SetMinMaxValues(1, 100) MySlider:SetValue(50) getglobal(MySlider:GetName() .. 'Low'):SetText('1'); getglobal(MySlider:GetName() .. 'High'):SetText('100'); getglobal(MySlider:GetName() .. 'Text'):SetText('My Slider'); MySlider:Show()
What you were missing before was the SetMinMaxValue, the SetValue and the fact that you were messing with the orientation and size. This frame looks like this:
If you want to make it vertical, you will need to write your own template. There is no getting around that. You will need to specify the placement of the font strings, and find an acceptable thumb texture.
-
Posted by Krafter on Fri, 08 May 2009 23:24:39
Thank you very much. I had to add:
MySlider:SetValueStep(1)
MySlider:SetScript("OnValueChanged", function() MyFunction() end)
to make it do something but I am well on my way. Thank you very much for your time and I love your book!!
-
Posted by jnwhiteh on Sat, 09 May 2009 09:41:34
Indeed, you'll need to add other things to make it more functional, but that's how the basic slider is created. Glad you're enjoying the book!
-
Posted by badintense on Fri, 07 May 2010 00:20:42
I have been having trouble accessing my scrolling message frame from my slider.
i can manipulate the slider fine from the message frame. my buttons move the scroll frame one line at a time either up or down even paging works and the slider position adjusts accordingly. but i cant seem to access myOutput1 (my scrolling message frame) from mySlider (my slider).
i created the xml using WOW UI Designer if that helps.
OnValueChanged works fine and I am able to print values to prove it is working, but it says it is nil when it tries to access myOutput1. I tried to use the GetGlobal but it just returns nil. there is no CreateFrame in my lua code, but I have been able to manipulate things by using the frame name set in the designer.
so what am i missing either in the ui designer or in my lua code?
-
Posted by jnwhiteh on Fri, 07 May 2010 17:54:11
I have been having trouble accessing my scrolling message frame from my slider.
i can manipulate the slider fine from the message frame. my buttons move the scroll frame one line at a time either up or down even paging works and the slider position adjusts accordingly. but i cant seem to access myOutput1 (my scrolling message frame) from mySlider (my slider).
i created the xml using WOW UI Designer if that helps.
OnValueChanged works fine and I am able to print values to prove it is working, but it says it is nil when it tries to access myOutput1. I tried to use the GetGlobal but it just returns nil. there is no CreateFrame in my lua code, but I have been able to manipulate things by using the frame name set in the designer.
so what am i missing either in the ui designer or in my lua code?
If you're trying to access
myOutput1
and getting that error, then it means that global variable isn't set. It's impossible to say without seeing the code (and I'm not sure I want to look at it).. but the error messages don't lie.