diff --git a/modules/corelib/ui/uiscrollarea.lua b/modules/corelib/ui/uiscrollarea.lua index b9732acf..5f274ecb 100644 --- a/modules/corelib/ui/uiscrollarea.lua +++ b/modules/corelib/ui/uiscrollarea.lua @@ -107,15 +107,37 @@ end function UIScrollArea:onMouseWheel(mousePos, mouseWheel) if self.verticalScrollBar then + if not self.verticalScrollBar:isOn() then + return false + end if mouseWheel == MouseWheelUp then + local minimum = self.verticalScrollBar:getMinimum() + if self.verticalScrollBar:getValue() <= minimum then + return false + end self.verticalScrollBar:decrement() else + local maximum = self.verticalScrollBar:getMaximum() + if self.verticalScrollBar:getValue() >= maximum then + return false + end self.verticalScrollBar:increment() end elseif self.horizontalScrollBar then + if not self.horizontalScrollBar:isOn() then + return false + end if mouseWheel == MouseWheelUp then + local maximum = self.horizontalScrollBar:getMaximum() + if self.horizontalScrollBar:getValue() >= maximum then + return false + end self.horizontalScrollBar:increment() else + local minimum = self.horizontalScrollBar:getMinimum() + if self.horizontalScrollBar:getValue() <= minimum then + return false + end self.horizontalScrollBar:decrement() end end diff --git a/modules/corelib/ui/uiscrollbar.lua b/modules/corelib/ui/uiscrollbar.lua index 236ec95c..c7ada55f 100644 --- a/modules/corelib/ui/uiscrollbar.lua +++ b/modules/corelib/ui/uiscrollbar.lua @@ -234,19 +234,23 @@ function UIScrollBar:onGeometryChange() end function UIScrollBar:onMouseWheel(mousePos, mouseWheel) - if not self.mouseScroll then + if not self.mouseScroll or not self:isOn() then return false end if mouseWheel == MouseWheelUp then if self.orientation == 'vertical' then + if self.value <= self.minimum then return false end self:decrement() else + if self.value >= self.maximum then return false end self:increment() end else if self.orientation == 'vertical' then + if self.value >= self.maximum then return false end self:increment() else + if self.value <= self.minimum then return false end self:decrement() end end diff --git a/modules/corelib/ui/uispinbox.lua b/modules/corelib/ui/uispinbox.lua index d3c1fca7..484d363c 100644 --- a/modules/corelib/ui/uispinbox.lua +++ b/modules/corelib/ui/uispinbox.lua @@ -7,11 +7,13 @@ function UISpinBox.create() spinbox:setValidCharacters('0123456789') spinbox.displayButtons = true spinbox.minimum = 0 - spinbox.maximum = 0 + spinbox.maximum = 1 spinbox.value = 0 spinbox.step = 1 spinbox.firstchange = true + spinbox.mouseScroll = true spinbox:setText("0") + spinbox:setValue(1) return spinbox end @@ -21,6 +23,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 +75,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 +164,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 \ No newline at end of file