Files
Basalt/docs/objects/Scrollbar.md
Robert Jelic b6114ca8da Update Scrollbar.md
Updated scrollbar example to make more sense
2023-05-18 22:09:23 +02:00

1.1 KiB

Scrollbars are objects that allow users to scroll vertically or horizontally, which in turn changes a value that you can access using the :getValue() method.

In addition to the Object and VisualObject methods, Scrollbar objects have the following methods:

setSymbol Sets the scrollbar symbol
setBackgroundSymbol Sets the background symbol
setBarType Sets the bar type (vertical or horizontal)
setScrollAmount Sets the maximum scroll amount
setIndex Sets the current index
getIndex Returns the index

Example

Here's an example of how to create a Scrollbar object and set its properties:

local main = basalt.createFrame()
local subFrame = main:addFrame():setSize(30, 15)
local scrollbar = main:addScrollbar():setPosition(31, 1):setSize(1, 15):setScrollAmount(10)

scrollbar:onChange(function(self, _, value)
  subFrame:setOffset(0, value-1)
end)