Improve scrollbar navigation

This commit is contained in:
Kamil Chojnowski 2019-01-05 18:13:36 +01:00
parent 07b4b785fc
commit 57a1f5eebe
1 changed files with 23 additions and 3 deletions

View File

@ -126,8 +126,8 @@ end
function UIScrollBar:onSetup() function UIScrollBar:onSetup()
self.setupDone = true self.setupDone = true
local sliderButton = self:getChildById('sliderButton') local sliderButton = self:getChildById('sliderButton')
g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end, 300) g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:onDecrement() end, 300)
g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() 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.bindPressMove(sliderButton, function(mousePos, mouseMoved) parseSliderPos(self, sliderButton, mousePos, mouseMoved) end)
g_mouse.bindPress(sliderButton, function(mousePos, mouseButton) parseSliderPress(self, sliderButton, mousePos, mouseButton) 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
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) function UIScrollBar:decrement(count)
count = count or self.step count = count or self.step
self:setValue(self.value - count) self:setValue(self.value - count)