Browse Source

Merge pull request #1006 from diath/improve_scrollbar_navigation

Improve scrollbar navigation
Konrad Kuśnierz 1 year ago
parent
commit
db3ba0f679
No account linked to committer's email address
1 changed files with 23 additions and 3 deletions
  1. 23
    3
      modules/corelib/ui/uiscrollbar.lua

+ 23
- 3
modules/corelib/ui/uiscrollbar.lua View File

@@ -126,8 +126,8 @@ end
126 126
 function UIScrollBar:onSetup()
127 127
   self.setupDone = true
128 128
   local sliderButton = self:getChildById('sliderButton')
129
-  g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end, 300)
130
-  g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end, 300)
129
+  g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:onDecrement() end, 300)
130
+  g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:onIncrement() end, 300)
131 131
   g_mouse.bindPressMove(sliderButton, function(mousePos, mouseMoved) parseSliderPos(self, sliderButton, mousePos, mouseMoved) end)
132 132
   g_mouse.bindPress(sliderButton, function(mousePos, mouseButton) parseSliderPress(self, sliderButton, mousePos, mouseButton) end)
133 133
 
@@ -158,6 +158,26 @@ function UIScrollBar:onStyleApply(styleName, styleNode)
158 158
   end
159 159
 end
160 160
 
161
+function UIScrollBar:onDecrement()
162
+  if g_keyboard.isCtrlPressed() then
163
+    self:decrement(self.value)
164
+  elseif g_keyboard.isShiftPressed() then
165
+    self:decrement(10)
166
+  else
167
+    self:decrement()
168
+  end
169
+end
170
+
171
+function UIScrollBar:onIncrement()
172
+  if g_keyboard.isCtrlPressed() then
173
+    self:increment(self.maximum)
174
+  elseif g_keyboard.isShiftPressed() then
175
+    self:increment(10)
176
+  else
177
+    self:increment()
178
+  end
179
+end
180
+
161 181
 function UIScrollBar:decrement(count)
162 182
   count = count or self.step
163 183
   self:setValue(self.value - count)
@@ -264,4 +284,4 @@ function UIScrollBar:getStep() return self.step end
264 284
 function UIScrollBar:getOrientation() return self.orientation end
265 285
 function UIScrollBar:getShowValue() return self.showValue end
266 286
 function UIScrollBar:getSymbol() return self.symbol end
267
-function UIScrollBar:getMouseScroll() return self.mouseScroll end
287
+function UIScrollBar:getMouseScroll() return self.mouseScroll end

Loading…
Cancel
Save