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.on_destroy()¶
Removes the event listeners and ends a drag in progress.
- 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.on_destroy()¶
Removes the event listeners and ends a drag in progress.
- 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. The scroll area sets
navigable = falseon it when initialized, so it is not a Tab stop.horizontalScrollbar : UIHorizontalScrollbar? - Optional horizontal scrollbar component. The scroll area sets
navigable = falseon it when initialized, so it is not a Tab stop.scrollSpeed : float = 25f - 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.
followFocus : bool = true - Whether to scroll a descendant of
contentinto view when it gets the UI focus, in the update after the focus change, once the layout has placed it.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: following the focus, arrow scrolling, inertia and bounce-back effects.
- UIScrollArea.on_destroy()¶
Removes the event listeners.
- UIScrollArea.handleMouseWheel(wheelDelta: float; shifts: KeyboardShifts): bool¶
Handles mouse wheel input and returns true if the event was consumed.
- Arguments:
wheelDelta : float
shifts : KeyboardShifts
Starts a smooth scroll by scrollSpeed per arrow press on an axis scrollDirection allows, within the
content and without inertia; while an arrow is held, handleNavigationScroll moves it instead, and a press
on that axis adds no distance.
Returns true if the event was consumed, false when the area cannot scroll that way or steps is zero.
- Arguments:
steps : int2
Scrolls smoothly while an arrow is held, by amount times 20 scrollSpeed steps per second of unscaled
time on an axis scrollDirection allows. Returns true if the event was consumed, false when the area cannot
scroll that way or amount is zero.
- Arguments:
amount : float2
- 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.
- UIScrollArea.scrollToNode(node: NodeId)¶
Scrolls the least distance that shows the frame of node, a descendant of content, inside the mask.
Scroll areas with followFocus between them scroll first; one with it off stays, so the node can stay hidden in
it. Only the axes scrollDirection allows move. On
an axis where the frame is larger than the mask, a frame that already covers the mask stays and one beside
it shows its top or left edge. Stops the wheel inertia and an arrow scroll when it scrolls. It reads the last layout, so for a
node that became active this frame call it in the next one.
- Arguments:
node : NodeId
- 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