Quantcast

Moved updating of the up/down button states from ScrollBar_Scroll() to the ScrollBar's OnValueChanged script handler.

James D. Callahan III [03-31-10 - 11:34]
Moved updating of the up/down button states from ScrollBar_Scroll() to the ScrollBar's OnValueChanged script handler.
Filename
Frame.lua
diff --git a/Frame.lua b/Frame.lua
index 1139af1..101fc7d 100644
--- a/Frame.lua
+++ b/Frame.lua
@@ -2524,13 +2524,6 @@ ScrollBar:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
 ScrollBar:SetMinMaxValues(0, 1)
 ScrollBar:SetValueStep(1)

--- This can be called either from ListFrame's OnMouseWheel script, manually
--- sliding the thumb, or from clicking the up/down buttons.
-ScrollBar:SetScript("OnValueChanged",
-		    function(self, value, ...)
-			    ListFrame:Update(nil, true)
-		    end)
-
 ListFrame.scroll_bar = ScrollBar

 -------------------------------------------------------------------------------
@@ -2578,17 +2571,6 @@ do
 			cur_val = math.max(min_val, cur_val - SCROLL_DEPTH)
 			ScrollBar:SetValue(cur_val)
 		end
-
-		if cur_val == min_val then
-			ScrollUpButton:Disable()
-			ScrollDownButton:Enable()
-		elseif cur_val == max_val then
-			ScrollUpButton:Enable()
-			ScrollDownButton:Disable()
-		else
-			ScrollUpButton:Enable()
-			ScrollDownButton:Enable()
-		end
 	end

 	ScrollUpButton:SetScript("OnClick",
@@ -2611,6 +2593,25 @@ do
 				    ScrollBar_Scroll(delta)
 			    end)

+	-- This can be called either from ListFrame's OnMouseWheel script, manually
+	-- sliding the thumb, or from clicking the up/down buttons.
+	ScrollBar:SetScript("OnValueChanged",
+			    function(self, value, ...)
+				    local min_val, max_val = self:GetMinMaxValues()
+
+				    if value == min_val then
+					    ScrollUpButton:Disable()
+					    ScrollDownButton:Enable()
+				    elseif value == max_val then
+					    ScrollUpButton:Enable()
+					    ScrollDownButton:Disable()
+				    else
+					    ScrollUpButton:Enable()
+					    ScrollDownButton:Enable()
+				    end
+				    ListFrame:Update(nil, true)
+			    end)
+
 	local function Button_OnEnter(self)
 		ListItem_ShowTooltip(self, ListFrame.entries[self.string_index])
 	end