3.4 KiB
3.4 KiB
ScrollBar
A ScrollBar element that can be attached to other elements to control their scroll properties
Extends: VisualElement
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| value | number | 0 | Current scroll value |
| min | number | 0 | Minimum scroll value |
| max | number | 100 | Maximum scroll value |
| step | number | 1 | Step size for scroll operations |
| dragMultiplier | number | 1 | How fast the ScrollBar moves when dragging |
| symbol | string | " | " Symbol used for the ScrollBar handle |
| backgroundSymbol | string | "\127" | Symbol used for the ScrollBar background |
| symbolBackgroundColor | color | black | Background color of the ScrollBar handle |
| backgroundSymbol | string | "\127" | Symbol used for the ScrollBar background |
| minValue | number | function | 0 |
| maxValue | number | function | 100 |
| orientation | string | vertical | Orientation of the ScrollBar ("vertical" or "horizontal") |
| handleSize | number | 2 | Size of the ScrollBar handle in characters |
Functions
| Method | Returns | Description |
|---|---|---|
| ScrollBar.new | ScrollBar | Creates a new ScrollBar instance |
| ScrollBar:init | ScrollBar | Initializes the ScrollBar instance |
| ScrollBar:attach | ScrollBar | Attaches the ScrollBar to an element's property |
| ScrollBar:updateAttachedElement | ScrollBar | Updates the attached element's property based on the ScrollBar value |
| ScrollBar:mouse_click | boolean | Handles mouse click events |
| ScrollBar:mouse_drag | boolean | Handles mouse drag events |
| ScrollBar:mouse_scroll | boolean | Handles mouse scroll events |
| ScrollBar:render | - | Renders the ScrollBar |
ScrollBar.new()
Creates a new ScrollBar instance
Returns
ScrollBarselfThe newly created ScrollBar instance
ScrollBar:init(props, basalt)
Parameters
propstableThe properties to initialize the element withbasalttableThe basalt instance
Returns
ScrollBarselfThe initialized instance
ScrollBar:attach(element, config)
Attaches the ScrollBar to an element's property
Parameters
elementBaseElementThe element to attach toconfigtableConfiguration {property = "propertyName", min = number|function, max = number|function}
Returns
ScrollBarselfThe ScrollBar instance
ScrollBar:updateAttachedElement()
Updates the attached element's property based on the ScrollBar value
Returns
ScrollBarselfThe ScrollBar instance
ScrollBar:mouse_click(button, x, y)
Parameters
buttonnumberThe mouse button clickedxnumberThe x position of the clickynumberThe y position of the click
Returns
booleanWhetherthe event was handled
ScrollBar:mouse_drag(button, x, y)
Parameters
buttonnumberThe mouse button being draggedxnumberThe x position of the dragynumberThe y position of the drag
Returns
booleanWhetherthe event was handled
ScrollBar:mouse_scroll(direction, x, y)
Parameters
directionnumberThe scroll direction (1 for up, -1 for down)xnumberThe x position of the scrollynumberThe y position of the scroll
Returns
booleanWhetherthe event was handled