ui.scroll
Overview
- Scrolls a scroll box or list view identified by a ref from ui.get_tree. By default it calls the scroll API directly, which lands on the target in one step and makes the result easy to verify; the response carries the resulting offset/max/pos/at_end so you do not have to re-query. Pass wheel=true with --delta to synthesize a real mouse wheel instead, which is what you want when the thing under test is wheel handling itself (nested scroll boxes, scroll propagation) - that path is animated, so the reported offset may still be settling. to=index only works on list views and is the reliable way to bring a virtualized item on screen: items outside the displayed range have no widget at all, so you must scroll them into view before ui.get_tree can see them or ui.click can touch them. For a scroll box the offset is in slate units; for a list view it is in items. Fails when there is no world or the ref is not scrollable.
Metadata
| Field | Value |
|---|---|
| Display | Scroll UI Widget |
| Category | ui |
| Access | UserCheat |
| Scope | B1Standalone |
| Tags | Experimental |
| Aliases | — |
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| ref | string | no | — | Scroll box or list view ref from ui.get_tree. |
| to | string | no | offset | Scroll destination. offset uses --offset or --delta; index uses --index (list views only). |
| offset | float | no | — | Absolute target offset for to=offset. |
| delta | float | no | — | Relative offset change for to=offset; with wheel=true this is the wheel tick count (positive scrolls up). |
| index | int | no | — | Item index to bring into view for to=index. |
| wheel | bool | no | false | Synthesize a mouse wheel event instead of calling the scroll API. |
Returns
Returns a JSON object with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
scrolled | bool | yes | Always true on success |
ref | string | yes | Ref that was scrolled |
method | string | yes | 'api' = direct scroll call. 'wheel' = synthesized wheel event |
offset | float | yes | Offset after the call. Slate units for a scroll box, items for a list view |
max | float | yes | Offset at the very end. For a list view this is approximated as (total items - displayed items) |
pos | float | yes | offset / max, 0-1 |
view | float | yes | Fraction of the content currently visible, 0-1 |
at_start | bool | yes | Whether the view is at the start |
at_end | bool | yes | Whether the view is at the end |
Usage
await inzoi.cli.execute('ui.scroll', {
ref: '', // optional
to: 'offset', // optional
offset: 0.0, // optional
delta: 0.0, // optional
index: 0, // optional
wheel: false, // optional
});