WoW:UIOBJECT Slider

From AddOn Studio
Revision as of 01:21, 1 February 2009 by WoWWiki>Kmcguire (New page: == Class Hierarchy, API, And Derivatives == For class hierarchy and method listing. See main listing here, Widget API Slider. == Notes == It is very difficult to fin...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Class Hierarchy, API, And Derivatives

For class hierarchy and method listing. See main listing here, Widget API Slider.

Notes

It is very difficult to find this information in other places. You mostly will find a listing of the methods the object supports but little else. Hopefully this will help, but if it still does not work then keep trying because it is only something simple that is wrong.

Construction

Using the CreateFrame() method, a template, and a built-in initialization function.

To create a slider and store it in a local variable (non-global) use this:

 local MySlider = CreateFrame('Slider', 'MySliderGlobalName', nil, 'OptionsSliderTemplate')

To create a slider as a global variable remove the local prefix from the statement (above).

The OptionsSliderTemplate provides the initial values. If you create the slider with out using the template you will have to set these values your self. I do not know exactly what these values are but I assume they are the textures and stuff so that calling the method Show() on the slider object will actually show something that is visible.

The difference between MySliderGlobalName and MySlider is that you have a local pointer to the object as MySlider and a few other objects created in the global scale with MySliderGlobalName. It sounds a little weird right? Well, I know but thats how they do things. In just a bit I will show and explain how to access these global objects that are created with MySliderGlobalName prefixed to them.

Construction With Parent Frame

To set a parent frame use:

 local MySlider = CreateFrame('Slider', nil, MyParentFrame, 'OptionsSliderTemplate')

One of the features of using a parent frame is that when the parent is hidden so are the children.

Width, Height, Orientation, And Position

After creating the slider you can set it's width and height using:

 MySlider:SetWidth(20)
 MySlider:SetHeight(100)

And, set its position on the screen or parent frame. In the example above I specifiy no parent frame.

 MySlider:SetPoint('TOPLEFT', 10, -10)

Also the orientation must not be forgotton. This says if the slider is a left to right (horizontal), or top to bottom (vertical). This is in reference to the direction the sliders slides.

 MySlider:SetOrientation('VERTICAL')

Or, for horizontal use:

 MySlider:SetOrientation('HORIZONTAL')

Special Global Objects Created By Template During Initialization

Some special objects where created when using the template during initialization (CreateFrame). You can access these objects using the LUA getglobal function. You should notice now and understand what I meant by the name we used in the CreateFrame function being prefixed to the name of these objects.

I have not really used these, but apparently they do something. So just experiment with them or hopefully someone will edit this WIKI page and explain them better.

 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');

Conclusion

After all that you can show your slider using:

 MySlider:Show()

I hope this helped a lot! I had so much trouble finding this information. And, what good is a list of object methods if you can not use the darn object??