WoW:UIOBJECT Slider: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
m (Added category)
Line 1: Line 1:
== Class Hierarchy, API, And Derivatives ==
== Class Hierarchy, API, And Derivatives ==
For class hierarchy and method listing.
For class hierarchy and method listing, see main listing here: [[Widget_API#Slider|Widget API Slider]].
See main listing here, [[Widget_API#Slider|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 ==
== Construction ==
Using the [[API_CreateFrame|CreateFrame()]] method, a template, and a built-in initialization function.
   local MySlider = CreateFrame("Slider", "MySliderGlobalName", ParentFrame, "OptionsSliderTemplate")
 
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 ==
== Width, Height, Orientation, And Position ==


After creating the slider you can set it's width and height using:
Width and height are handled the same as any other widget:
   MySlider:SetWidth(20)
   MySlider:SetWidth(20)
   MySlider:SetHeight(100)
   MySlider:SetHeight(100)


And, set its position on the screen or parent frame. In the example above I specifiy no parent frame.
To set your slider to a vertical orientation:
  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')
   MySlider:SetOrientation('VERTICAL')
Or, for horizontal use:
Or for a horizontal slider:
   MySlider:SetOrientation('HORIZONTAL')
   MySlider:SetOrientation('HORIZONTAL')


== Special Global Objects Created By Template During Initialization ==
== Special Global Objects Created By Template During Initialization ==
Some special objects where created when using the template during initialization (CreateFrame). You can
Some special objects are created when using the "OptionsSliderTemplate" template during initialization (CreateFrame). You can
access these objects using the LUA '''getglobal''' function. You should notice now and understand what
access these objects using the LUA '''getglobal''' function, as outlined below:
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
   MySlider.tooltipText = 'This is the Tooltip hint' --Creates a tooltip on mouseover.
someone will edit this WIKI page and explain them better.
   getglobal(MySlider:GetName() .. 'Low'):SetText('1'); --Sets the left-side slider text (default is "Low").
   MySlider.tooltipText = 'This is the Tooltip hint'  
   getglobal(MySlider:GetName() .. 'High'):SetText('100'); --Sets the right-side slider text (default is "High").
   getglobal(MySlider:GetName() .. 'Low'):SetText('1');
   getglobal(MySlider:GetName() .. 'Text'):SetText('5'); --Sets the "title" text (top-centre of slider).
   getglobal(MySlider:GetName() .. 'High'):SetText('100');  
 
   getglobal(MySlider:GetName() .. 'Text'):SetText('5');
These are useful shortcuts in lieu of having to manually define font strings.


== Conclusion ==
== Conclusion ==
After all that you can show your slider using:
After all that you can show your slider using:
   MySlider:Show()
   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??
<br><br>
[[Category:Widgets]]
[[Category:Widgets]]

Revision as of 17:20, 9 April 2010

Class Hierarchy, API, And Derivatives

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

Construction

 local MySlider = CreateFrame("Slider", "MySliderGlobalName", ParentFrame, "OptionsSliderTemplate")

Width, Height, Orientation, And Position

Width and height are handled the same as any other widget:

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

To set your slider to a vertical orientation:

 MySlider:SetOrientation('VERTICAL')

Or for a horizontal slider:

 MySlider:SetOrientation('HORIZONTAL')

Special Global Objects Created By Template During Initialization

Some special objects are created when using the "OptionsSliderTemplate" template during initialization (CreateFrame). You can access these objects using the LUA getglobal function, as outlined below:

 MySlider.tooltipText = 'This is the Tooltip hint' --Creates a tooltip on mouseover.
 getglobal(MySlider:GetName() .. 'Low'):SetText('1'); --Sets the left-side slider text (default is "Low").
 getglobal(MySlider:GetName() .. 'High'):SetText('100'); --Sets the right-side slider text (default is "High").
 getglobal(MySlider:GetName() .. 'Text'):SetText('5'); --Sets the "title" text (top-centre of slider).

These are useful shortcuts in lieu of having to manually define font strings.

Conclusion

After all that you can show your slider using:

 MySlider:Show()