UIScrollArea
Enumerations
- ScrollDirection
Defines the scrolling direction for a scroll area.
- Values:
Vertical = 0 - Only vertical scrolling is enabled.
Horizontal = 1 - Only horizontal scrolling is enabled.
Both = 2 - Both vertical and horizontal scrolling are enabled.
Classes
- UIVerticalScrollbar : UIComponent
Note
UIFrame component is automatically added to the node if it is not already present
A vertical scrollbar UI component with proportional handle sizing. The handle size automatically adjusts based on the visible ratio.
- Fields:
visibleRatio : float = 0.5f - Ratio of visible content to total content (0-1). Controls handle size.
onChange : lambda<(offset:float):void> - Called when the scroll value changes via drag.
handle : UIFrame? - The frame component representing the scrollbar handle.
track : UIFrame? - The frame component representing the scrollbar track. If left empty, the frame of the node itself will be used.
- UIVerticalScrollbar.on_initialize()
Initializes the scrollbar and sets up event listeners.
- UIVerticalScrollbar.setValue(newValue: float): bool
Sets the scroll offset value and updates the handle position.
- Arguments:
newValue : float
- UIVerticalScrollbar.invalidate()
Updates the handle position and size based on scroll value and visible ratio.
- UIVerticalScrollbar.start_drag(): bool
Initializes the drag operation.
- UIVerticalScrollbar.update_drag()
Updates the scroll value based on the current mouse position.
- Properties:
- UIVerticalScrollbar.value: float
Returns the current scroll offset value.
- UIVerticalScrollbar.value =(newValue: float)
Sets the scroll offset value and updates the handle position.
- Arguments:
newValue : float
- UIHorizontalScrollbar : UIComponent
Note
UIFrame component is automatically added to the node if it is not already present
A horizontal scrollbar UI component with proportional handle sizing. The handle size automatically adjusts based on the visible ratio.
- Fields:
visibleRatio : float = 0.5f - Ratio of visible content to total content (0-1). Controls handle size.
onChange : lambda<(offset:float):void> - Called when the scroll value changes via drag.
handle : UIFrame? - The frame component representing the scrollbar handle.
track : UIFrame? - The frame component representing the scrollbar track. If left empty, the frame of the node itself will be used.
- UIHorizontalScrollbar.on_initialize()
Initializes the scrollbar and sets up event listeners.
- UIHorizontalScrollbar.setValue(newValue: float): bool
Sets the scroll offset value and updates the handle position.
- Arguments:
newValue : float
- UIHorizontalScrollbar.invalidate()
Updates the handle position and size based on scroll value and visible ratio.
- UIHorizontalScrollbar.start_drag(): bool
Initializes the drag operation.
- UIHorizontalScrollbar.update_drag()
Updates the scroll value based on the current mouse position.
- Properties:
- UIHorizontalScrollbar.value: float
Returns the current scroll offset value.
- UIHorizontalScrollbar.value =(newValue: float)
Sets the scroll offset value and updates the handle position.
- Arguments:
newValue : float
- UIScrollArea : UIComponent
Note
UIFrame component is automatically added to the node if it is not already present
A scroll area UI component that allows scrolling content behind a mask. The mask defines the visible area, and the content can be scrolled vertically and/or horizontally.
Usage example:
def init_scroll_area() {
get_component(node) $(var scrollArea : UIScrollArea?) {
scrollArea.scrollSpeed = 20.0
scrollArea.onScroll = @(offset : float2) { print("Scrolled to {offset}") }
}
}
- Fields:
content : UIFrame? - The frame component representing the scrollable content.
maskArea : UIMask? - The mask component defining the visible area. Note that the content node should be a child of the mask node for proper masking to work.
verticalScrollbar : UIVerticalScrollbar? - Optional vertical scrollbar component.
horizontalScrollbar : UIHorizontalScrollbar? - Optional horizontal scrollbar component.
scrollSpeed : float = 5f - Speed of scrolling.
scrollDirection : ScrollDirection = ui_scroll_area_component::ScrollDirection.Both - The scrolling direction (Vertical, Horizontal, or Both).
enableOverscroll : bool = true - Whether to allow overscrolling beyond bounds with elastic bounce-back effect.
elasticity : float = 0.1f - Elasticity of overscroll bounce-back (how quickly it springs back).
maxOverscrollRatio : float = 0.5f - Maximum overscroll distance as a ratio of the mask size.
enableInertia : bool = true - Whether to enable inertia/momentum scrolling after input stops.
decelerationRate : float = 0.135f - Rate at which scrolling decelerates after input stops. Lower values = slower deceleration.
onScroll : lambda<(offset:float2):void> - Called when the scroll offset changes.
- UIScrollArea.on_initialize()
Initializes the scroll area and sets up event listeners.
- UIScrollArea.on_update()
Updates scroll area state, including inertia and bounce-back effects.
- UIScrollArea.handleMouseWheel(wheelDelta: float; shifts: KeyboardShifts): bool
Handles mouse wheel input and returns true if the event was consumed.
- Arguments:
wheelDelta : float
shifts : KeyboardShifts
- UIScrollArea.updateScrollbarRanges()
Updates the scrollbar handle sizes and interactability based on content and mask sizes.
- UIScrollArea.setScrollOffset(newOffset: float2): bool
Sets the scroll offset and updates the content position.
- Arguments:
newOffset : float2
- UIScrollArea.invalidate()
Updates the content position based on scroll offset.
- UIScrollArea.scroll(delta: float2)
Scrolls by the given delta amount, applying resistance if overscrolling is enabled.
- Arguments:
delta : float2
- UIScrollArea.scrollToTop()
Scrolls to the top of the content.
- UIScrollArea.scrollToBottom()
Scrolls to the bottom of the content.
- UIScrollArea.scrollToLeft()
Scrolls to the left of the content.
- UIScrollArea.scrollToRight()
Scrolls to the right of the content.
- Properties:
- UIScrollArea.scrollOffset: float2
Returns the current scroll offset.
- UIScrollArea.scrollOffset =(newOffset: float2)
Sets the scroll offset and updates the content position.
- Arguments:
newOffset : float2