From 57a1f5eebe589e5bacf3587ed9879035e9dda37c Mon Sep 17 00:00:00 2001 From: Kamil Chojnowski Date: Sat, 5 Jan 2019 18:13:36 +0100 Subject: [PATCH] Improve scrollbar navigation --- modules/corelib/ui/uiscrollbar.lua | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/corelib/ui/uiscrollbar.lua b/modules/corelib/ui/uiscrollbar.lua index 387ba313..76c2d07c 100644 --- a/modules/corelib/ui/uiscrollbar.lua +++ b/modules/corelib/ui/uiscrollbar.lua @@ -126,8 +126,8 @@ end function UIScrollBar:onSetup() self.setupDone = true local sliderButton = self:getChildById('sliderButton') - g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end, 300) - g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end, 300) + g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:onDecrement() end, 300) + g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:onIncrement() end, 300) g_mouse.bindPressMove(sliderButton, function(mousePos, mouseMoved) parseSliderPos(self, sliderButton, mousePos, mouseMoved) end) g_mouse.bindPress(sliderButton, function(mousePos, mouseButton) parseSliderPress(self, sliderButton, mousePos, mouseButton) end) @@ -158,6 +158,26 @@ function UIScrollBar:onStyleApply(styleName, styleNode) end end +function UIScrollBar:onDecrement() + if g_keyboard.isCtrlPressed() then + self:decrement(self.value) + elseif g_keyboard.isShiftPressed() then + self:decrement(10) + else + self:decrement() + end +end + +function UIScrollBar:onIncrement() + if g_keyboard.isCtrlPressed() then + self:increment(self.maximum) + elseif g_keyboard.isShiftPressed() then + self:increment(10) + else + self:increment() + end +end + function UIScrollBar:decrement(count) count = count or self.step self:setValue(self.value - count) @@ -264,4 +284,4 @@ function UIScrollBar:getStep() return self.step end function UIScrollBar:getOrientation() return self.orientation end function UIScrollBar:getShowValue() return self.showValue end function UIScrollBar:getSymbol() return self.symbol end -function UIScrollBar:getMouseScroll() return self.mouseScroll end \ No newline at end of file +function UIScrollBar:getMouseScroll() return self.mouseScroll end