diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index c7994a001..f25eb0f56 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -4377,6 +4377,10 @@ direction. The amount of scrolling done in each case in determined by the associated widget, and after scrolling is complete, the associated widget must call ``scrollbar:update()`` with updated new display info. +If the mouse wheel is scrolled while the mouse is over the Scrollbar widget's +parent view, then the parent is scrolled accordingly. Holding :kbd:`Shift` +while scrolling will result in faster movement. + You can click and drag the scrollbar to scroll to a specific spot, or you can click and hold on the end arrows or in the unfilled portion of the scrollbar to scroll multiple times, just like in a normal browser scrollbar. The speed of diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index 222ee2167..f77c31063 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -27,16 +27,12 @@ end STANDARDSCROLL = { STANDARDSCROLL_UP = -1, KEYBOARD_CURSOR_UP = -1, - CONTEXT_SCROLL_UP = -1, STANDARDSCROLL_DOWN = 1, KEYBOARD_CURSOR_DOWN = 1, - CONTEXT_SCROLL_DOWN = 1, STANDARDSCROLL_PAGEUP = '-page', KEYBOARD_CURSOR_UP_FAST = '-page', - CONTEXT_SCROLL_PAGEUP = '-page', STANDARDSCROLL_PAGEDOWN = '+page', KEYBOARD_CURSOR_DOWN_FAST = '+page', - CONTEXT_SCROLL_PAGEDOWN = '+page', } ------------ @@ -934,10 +930,26 @@ function Scrollbar:onRenderBody(dc) end function Scrollbar:onInput(keys) - if not keys._MOUSE_L_DOWN or not self.on_scroll - or not scrollbar_is_visible(self) then + if not self.on_scroll or not scrollbar_is_visible(self) then return false end + + if self.parent_view:getMousePos() then + if keys.CONTEXT_SCROLL_UP then + self.on_scroll('up_small') + return true + elseif keys.CONTEXT_SCROLL_DOWN then + self.on_scroll('down_small') + return true + elseif keys.CONTEXT_SCROLL_PAGEUP then + self.on_scroll('up_large') + return true + elseif keys.CONTEXT_SCROLL_PAGEDOWN then + self.on_scroll('down_large') + return true + end + end + if not keys._MOUSE_L_DOWN then return false end local _,y = self:getMousePos() if not y then return false end local scroll_spec = nil