XU XUv0.13.1
中文

UI / WIDGETS / Navigation

Pagination

Move through paginated data

Run the Xu example

The example executes in the browser using the Xu/WASM runtime.

What to try

Switch pages and observe the current page number.

Usage notes

Keep page count, current page and page size synchronized with the data. Pagination requests a change; the application loads the data.

Create through Screen

The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.

Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.

#ui/widgets

fn configure(screen $&widgets.Screen) int {
    id := screen.pagination(4,0) or >>
    screen.place(id,24.0,24.0,320.0,80.0) or >>
    << id
}

($&Screen) pagination

XuAPI
pub fn (s $&Screen) pagination(pages int,current int) int

Purpose

Create Pagination in Screen and return the component node ID; throw on creation failure.

Parameters

s $&Screen
The Screen instance used by this call (exclusive borrow).
pages int
pages (int)
current int
current (int)

Returns

int — component node ID for place and other Screen methods.

Placement, state and events

The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.

Action · Styles · UI lifecycle and styling guide

Screen.place · Screen.set_enabled · Screen.set_visible

Standalone control object API

These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.

($&Pagination) set_locale

XuAPI
pub fn (page $&Pagination) set_locale(locale &Locale) int

Purpose

Operation on $&Pagination: set locale. Throws on failure; handle the error or propagate it to the caller.

Parameters

page $&Pagination
The Pagination instance used by this call (exclusive borrow).
locale &Locale
locale (read-only borrow; caller keeps the original; type &Locale)

Returns

int — a value of this type

struct Pagination

XuAPI
pub struct Pagination {

}

Purpose

Zero based page state. Endpoints and a bounded page window are materialized; callers retain ownership of the actual paged data. Zero pages has current == -1.

Public fields

This type has no public fields.

(&Pagination) id

XuAPI
pub fn (p &Pagination) id() int

Purpose

Return the unique integer ID of the element or control.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

int — a value of this type

(&Pagination) bounds

XuAPI
pub fn (p &Pagination) bounds() layout.Rect

Purpose

Return the bounding Rectangle of the control or geometry.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

layout.Rect — a value of this type

(&Pagination) page_count

XuAPI
pub fn (p &Pagination) page_count() int

Purpose

Operation on &Pagination: page count.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

int — a value of this type

(&Pagination) selected

XuAPI
pub fn (p &Pagination) selected() int

Purpose

Get or test the currently selected index, node, or state.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

int — a value of this type

(&Pagination) needs_paint

XuAPI
pub fn (p &Pagination) needs_paint() bool

Purpose

Return whether the control needs repainting; call painted after painting to clear the flag.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

bool — true or false

($&Pagination) painted

XuAPI
pub fn (p $&Pagination) painted()

Purpose

Acknowledge the painted frame and clear the dirty flag; this is not a query.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).

Returns

This call does not return a value.

(&Pagination) is_enabled

XuAPI
pub fn (p &Pagination) is_enabled() bool

Purpose

Return whether the control is currently enabled.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

bool — true or false

(&Pagination) is_selectable

XuAPI
pub fn (p &Pagination) is_selectable() bool

Purpose

Operation on &Pagination: whether it is selectable.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

bool — true or false

($&Pagination) set_selectable

XuAPI
pub fn (p $&Pagination) set_selectable(selectable bool)

Purpose

Operation on $&Pagination: set selectable.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
selectable bool
selectable (bool)

Returns

This call does not return a value.

(&Pagination) is_focused

XuAPI
pub fn (p &Pagination) is_focused() bool

Purpose

Return whether the control currently has input focus.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

bool — true or false

(&Pagination) is_read_only

XuAPI
pub fn (p &Pagination) is_read_only() bool

Purpose

Operation on &Pagination: whether it is read only.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).

Returns

bool — true or false

($&Pagination) cancel

XuAPI
pub fn (p $&Pagination) cancel()

Purpose

Execute cancel on $&Pagination.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Pagination) set_focus

XuAPI
pub fn (p $&Pagination) set_focus(focused bool)

Purpose

Operation on $&Pagination: set focus.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
focused bool
focused (bool)

Returns

This call does not return a value.

($&Pagination) set_enabled

XuAPI
pub fn (p $&Pagination) set_enabled(enabled bool)

Purpose

Operation on $&Pagination: set enabled.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
enabled bool
enabled (bool)

Returns

This call does not return a value.

($&Pagination) set_read_only

XuAPI
pub fn (p $&Pagination) set_read_only(value bool) int

Purpose

Operation on $&Pagination: set read only. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
value bool
value (bool)

Returns

int — a value of this type

($&Pagination) set_page_count

XuAPI
pub fn (p $&Pagination) set_page_count(pages int) int

Purpose

Operation on $&Pagination: set page count. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
pages int
pages (int)

Returns

int — a value of this type

($&Pagination) set_selected

XuAPI
pub fn (p $&Pagination) set_selected(index int) int

Purpose

Operation on $&Pagination: set selected. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
index int
index (int)

Returns

int — a value of this type

($&Pagination) set_bounds

XuAPI
pub fn (p $&Pagination) set_bounds(bounds &layout.Rect) int

Purpose

Operation on $&Pagination: set bounds. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
bounds &layout.Rect
bounds (read-only borrow; caller keeps the original; type &layout.Rect)

Returns

int — a value of this type

(&Pagination) style_or

XuAPI
pub fn (p &Pagination) style_or(styles &Styles) ControlStyle

Purpose

Operation on &Pagination: style or.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

ControlStyle — a value of this type

($&Pagination) set_style

XuAPI
pub fn (p $&Pagination) set_style(style &ControlStyle) int

Purpose

Operation on $&Pagination: set style. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
style &ControlStyle
style (read-only borrow; caller keeps the original; type &ControlStyle)

Returns

int — a value of this type

($&Pagination) clear_style

XuAPI
pub fn (p $&Pagination) clear_style()

Purpose

Operation on $&Pagination: clear style.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Pagination) apply_styles

XuAPI
pub fn (p $&Pagination) apply_styles(styles &Styles) int

Purpose

Resolve and apply theme metrics to the control. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

(&Pagination) item_bounds

XuAPI
pub fn (p &Pagination) item_bounds(slot int) layout.Rect

Purpose

Operation on &Pagination: item bounds.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).
slot int
slot (int)

Returns

layout.Rect — a value of this type

($&Pagination) input

XuAPI
pub fn (p $&Pagination) input(input &ui.InputEvent) Action

Purpose

Process routed mouse, keyboard, or touch input events.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
input &ui.InputEvent
input (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&Pagination) route

XuAPI
pub fn (p $&Pagination) route(kind int,input &ui.InputEvent) Action

Purpose

Route and dispatch the input event to matching targets. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
kind int
kind tag (int)
input &ui.InputEvent
input (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&Pagination) event

XuAPI
pub fn (p $&Pagination) event(event &ui.Event) Action

Purpose

Handle and respond to window or system lifecycle and interaction events. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
event &ui.Event
event (read-only borrow; caller keeps the original; type &ui.Event)

Returns

Action — input result with kind, id, repaint and focus requests.

($&Pagination) measure_styled

XuAPI
pub fn (p $&Pagination) measure_styled(styles &Styles) layout.Size

Purpose

Operation on $&Pagination: measure styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

layout.Size — a value of this type

($&Pagination) paint_styled

XuAPI
pub fn (p $&Pagination) paint_styled(frame $&draw.Frame,styles &Styles) int

Purpose

Operation on $&Pagination: paint styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
frame $&draw.Frame
frame (exclusive borrow; may modify the original; type $&draw.Frame)
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

($&Pagination) dispose

XuAPI
pub fn (p $&Pagination) dispose()

Purpose

Release and dispose native resources and underlying handles.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Pagination) set_appearance

XuAPI
pub fn (page $&Pagination) set_appearance(appearance &PaginationAppearance) int

Purpose

Operation on $&Pagination: set appearance. Throws on failure; handle the error or propagate it to the caller.

Parameters

page $&Pagination
The Pagination instance used by this call (exclusive borrow).
appearance &PaginationAppearance
appearance (read-only borrow; caller keeps the original; type &PaginationAppearance)

Returns

int — a value of this type

(&Pagination) data

XuAPI
pub fn (page &Pagination) data() PaginationData

Purpose

Execute data on &Pagination.

Parameters

page &Pagination
The Pagination instance used by this call (borrow).

Returns

PaginationData — a value of this type

($&Pagination) set_data

XuAPI
pub fn (page $&Pagination) set_data(total int,page_size int) int

Purpose

Keep the first item being viewed visible when page size changes. Throws on failure; handle the error or propagate it to the caller.

Parameters

page $&Pagination
The Pagination instance used by this call (exclusive borrow).
total int
total (int)
page_size int
page_size (int)

Returns

int — a value of this type

($&Pagination) jump

XuAPI
pub fn (page $&Pagination) jump(one_based int) int

Purpose

Execute jump on $&Pagination. Throws on failure; handle the error or propagate it to the caller.

Parameters

page $&Pagination
The Pagination instance used by this call (exclusive borrow).
one_based int
one_based (int)

Returns

int — a value of this type

(&Pagination) summary_text

XuAPI
pub fn (page &Pagination) summary_text() string

Purpose

Operation on &Pagination: summary text. Throws on failure; handle the error or propagate it to the caller.

Parameters

page &Pagination
The Pagination instance used by this call (borrow).

Returns

string — result string

($&Pagination) set_motion

XuAPI
pub fn (p $&Pagination) set_motion(spec &MotionSpec) int

Purpose

Operation on $&Pagination: set motion. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
spec &MotionSpec
spec (read-only borrow; caller keeps the original; type &MotionSpec)

Returns

int — a value of this type

($&Pagination) tick

XuAPI
pub fn (p $&Pagination) tick(styles &Styles,now time.Instant,reduced bool) bool

Purpose

Advance animation clock and state transition step. Throws on failure; handle the error or propagate it to the caller.

Parameters

p $&Pagination
The Pagination instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)
now time.Instant
now (time.Instant)
reduced bool
reduced (bool)

Returns

bool — true or false

(&Pagination) next_tick

XuAPI
pub fn (p &Pagination) next_tick(now time.Instant) time.Instant

Purpose

Operation on &Pagination: next tick. Throws on failure; handle the error or propagate it to the caller.

Parameters

p &Pagination
The Pagination instance used by this call (borrow).
now time.Instant
now (time.Instant)

Returns

time.Instant — a value of this type

Complete native example

Component Workshop · Back to Widgets