Avoid ending mouse scroll chain when scroll bar is 'off'.

Also added mouse-scroll style to UISpinBox.
master
BenDol 10 years ago
parent 07ac5c27ca
commit 5909634837

@ -107,12 +107,18 @@ end
function UIScrollArea:onMouseWheel(mousePos, mouseWheel) function UIScrollArea:onMouseWheel(mousePos, mouseWheel)
if self.verticalScrollBar then if self.verticalScrollBar then
if not self.verticalScrollBar:isOn() then
return false
end
if mouseWheel == MouseWheelUp then if mouseWheel == MouseWheelUp then
self.verticalScrollBar:decrement() self.verticalScrollBar:decrement()
else else
self.verticalScrollBar:increment() self.verticalScrollBar:increment()
end end
elseif self.horizontalScrollBar then elseif self.horizontalScrollBar then
if not self.horizontalScrollBar:isOn() then
return false
end
if mouseWheel == MouseWheelUp then if mouseWheel == MouseWheelUp then
self.horizontalScrollBar:increment() self.horizontalScrollBar:increment()
else else

@ -11,6 +11,7 @@ function UISpinBox.create()
spinbox.value = 0 spinbox.value = 0
spinbox.step = 1 spinbox.step = 1
spinbox.firstchange = true spinbox.firstchange = true
spinbox.mouseScroll = true
spinbox:setText("0") spinbox:setText("0")
return spinbox return spinbox
end end
@ -21,6 +22,9 @@ function UISpinBox:onSetup()
end end
function UISpinBox:onMouseWheel(mousePos, direction) function UISpinBox:onMouseWheel(mousePos, direction)
if not self.mouseScroll then
return false
end
if direction == MouseWheelUp then if direction == MouseWheelUp then
self:up() self:up()
elseif direction == MouseWheelDown then elseif direction == MouseWheelDown then
@ -70,6 +74,8 @@ function UISpinBox:onStyleApply(styleName, styleNode)
addEvent(function() self:setMaximum(value) end) addEvent(function() self:setMaximum(value) end)
elseif name == 'minimum' then elseif name == 'minimum' then
addEvent(function() self:setMinimum(value) end) addEvent(function() self:setMinimum(value) end)
elseif name == 'mouse-scroll' then
addEvent(function() self:setMouseScroll(value) end)
elseif name == 'buttons' then elseif name == 'buttons' then
addEvent(function() addEvent(function()
if value then if value then
@ -157,3 +163,11 @@ end
function UISpinBox:setStep(step) function UISpinBox:setStep(step)
self.step = step or 1 self.step = step or 1
end end
function UISpinBox:setMouseScroll(mouseScroll)
self.mouseScroll = mouseScroll
end
function UISpinBox:getMouseScroll()
return self.mouseScroll
end
Loading…
Cancel
Save