Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
(Created page with "{{widgethandler}}<br> == Description == Called whenever the value of the slider was changed, or the thumb of the slider is being moved. Note that this will call even if the...")
Tag: WoW API docs
 
(Fixed examples formatting)
Tags: WoW API docs Visual edit
Line 17: Line 17:
 
MySlider:SetOrientation('HORIZONTAL')
 
MySlider:SetOrientation('HORIZONTAL')
 
MySlider:SetScript("OnValueChanged", function(self,value,userInput)
 
MySlider:SetScript("OnValueChanged", function(self,value,userInput)
if userInput then
+
if userInput then
print("Hey! Quit Dragging me!")
+
print("Hey! Quit Dragging me!")
else
+
else
print("Oo, I moved without being touched! Spooky!")
+
print("Oo, I moved without being touched! Spooky!")
end
+
end
 
end)
 
end)
   
   
 
The named arguments are also available in XML handlers:
 
The named arguments are also available in XML handlers:
<Slider name="MySlider_Template" orientation="HORIZONTAL" enableMouse="true" virtual="true">
+
<Slider name="MySlider_Template" orientation="HORIZONTAL" enableMouse="true" virtual="true">
<Size x="144" y="17"/>
+
<Size x="144" y="17"/>
<Backdrop bgFile="Interface\Buttons\UI-SliderBar-Background"
+
<Backdrop bgFile="Interface\Buttons\UI-SliderBar-Background" edgeFile="Interface\Buttons\UI-SliderBar-Border" tile="true">
 
<EdgeSize val="8"/>
edgeFile="Interface\Buttons\UI-SliderBar-Border" tile="true">
 
<EdgeSize val="8"/>
+
<TileSize val="8"/>
 
<BackgroundInsets left="3" right="3" top="6" bottom="6"/>
<TileSize val="8"/>
 
 
</Backdrop>
<BackgroundInsets left="3" right="3" top="6" bottom="6"/>
 
 
<ThumbTexture name="$parentThumb" file="Interface\Buttons\UI-SliderBar-Button-Horizontal">
</Backdrop>
 
 
<Size x="32" y="32"/>
<ThumbTexture name="$parentThumb" file="Interface\Buttons\UI-SliderBar-Button-Horizontal">
 
 
</ThumbTexture>
<Size x="32" y="32"/>
 
 
<Scripts>
</ThumbTexture>
 
 
<OnValueChanged>
<Scripts>
 
 
if userInput then
<OnValueChanged>
 
 
print("Hey! Quit Dragging me!")
if userInput then
 
 
else
print("Hey! Quit Dragging me!")
 
 
print("Oo, I moved without being touched! Spooky!")
else
 
  +
end
print("Oo, I moved without being touched! Spooky!")
 
 
</OnValueChanged>
end
 
  +
</Scripts>
</OnValueChanged>
 
</Scripts>
+
</Slider>
</Slider>
 

Revision as of 00:20, 14 June 2021


Description

Called whenever the value of the slider was changed, or the thumb of the slider is being moved. Note that this will call even if the value has not actually changed the thumb is dragged.

Arguments

self
Table - the widget being clicked
value
Number - the new value of the slider
userInput
Boolean - True if set directly by the thumb being moved, False if set by slider:SetValue().

Example

local MySlider = CreateFrame("Slider", "MySliderGlobalName", ParentFrame, "OptionsSliderTemplate")
MySlider:SetWidth(20)
MySlider:SetHeight(100)
MySlider:SetOrientation('HORIZONTAL')
MySlider:SetScript("OnValueChanged", function(self,value,userInput)
	if userInput then 
		print("Hey! Quit Dragging me!")
	else
		print("Oo, I moved without being touched! Spooky!")
	end
end)


The named arguments are also available in XML handlers:

<Slider name="MySlider_Template" orientation="HORIZONTAL" enableMouse="true" virtual="true"> 
	<Size x="144" y="17"/> 
	<Backdrop bgFile="Interface\Buttons\UI-SliderBar-Background" edgeFile="Interface\Buttons\UI-SliderBar-Border" tile="true">
		<EdgeSize val="8"/> 
		<TileSize val="8"/>
		<BackgroundInsets left="3" right="3" top="6" bottom="6"/>
	</Backdrop>
	<ThumbTexture name="$parentThumb" file="Interface\Buttons\UI-SliderBar-Button-Horizontal">
		<Size x="32" y="32"/>
	</ThumbTexture>
	<Scripts>
	<OnValueChanged> 
		if userInput then 
			print("Hey! Quit Dragging me!") 
		else
			print("Oo, I moved without being touched! Spooky!")
		end
	</OnValueChanged>
	</Scripts>
</Slider>