UIOBJECT Slider

From Wowpedia
Jump to: navigation, search

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

Callbacks

Events fired by the widget for which you can set handlers are listed here.

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 their global names, as outlined below (as of patch 4.3, these fields have no "parentKey" attribute):

 MySlider.tooltipText = 'This is the Tooltip hint'   -- Creates a tooltip on mouseover.
 _G[MySlider:GetName() .. 'Low']:SetText('1')        -- Sets the left-side slider text (default is "Low").
 _G[MySlider:GetName() .. 'High']:SetText('100')     -- Sets the right-side slider text (default is "High").
 _G[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. The "OptionsSliderTemplate" is defined in FrameXML/OptionsPanelTemplates.xml for further reference.

Conclusion

After all that you can show your slider using:

 MySlider:Show()