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)
if self.verticalScrollBar then
if not self.verticalScrollBar:isOn() then
return false
end
if mouseWheel == MouseWheelUp then
self.verticalScrollBar:decrement()
else
self.verticalScrollBar:increment()
end
elseif self.horizontalScrollBar then
if not self.horizontalScrollBar:isOn() then
return false
end
if mouseWheel == MouseWheelUp then
self.horizontalScrollBar:increment()
else

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