What to try
Click a column header to change sorting.
Usage notes
Column types determine sorting semantics. Sort numeric columns by value and balance column and minimum widths against available space.
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 {
options := ["Design","Develop","Review"]
id := screen.table(&options,3,0) or >>
screen.place(id,24.0,24.0,320.0,80.0) or >>
<< id
}
($&Screen) table
pub fn (s $&Screen) table(headers &[]string,rows int,selected int) int
Purpose
Create Table in Screen and return the component node ID; throw on creation failure.
Parameters
s $&Screen- The
Screen instance used by this call (exclusive borrow).
headers &[]string- headers (read-only borrow; caller keeps the original; type &[]string)
rows int- rows (int)
selected int- selected (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.
($&Table) set_locale
pub fn (table $&Table) set_locale(locale &Locale) int
Purpose
Operation on $&Table: set locale. Throws on failure; handle the error or propagate it to the caller.
Parameters
table $&Table- The
Table 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 Table
Purpose
A bounded single-line, equal-width column table: 1..16 columns and at most 768 cells (512 rows). Header activation sorts locally unless manual mode is set. Only visible rows are shaped, and their cache slots are reused on scroll.
Public fields
This type has no public fields.
(&Table) id
pub fn (t &Table) id() int
Purpose
Return the unique integer ID of the element or control.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
int — a value of this type
(&Table) bounds
pub fn (t &Table) bounds() layout.Rect
Purpose
Return the bounding Rectangle of the control or geometry.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
layout.Rect — a value of this type
(&Table) count
pub fn (t &Table) count() int
Purpose
Return the number of items in this control.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
int — a value of this type
(&Table) column_count
pub fn (t &Table) column_count() int
Purpose
Operation on &Table: column count.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
int — a value of this type
(&Table) selected
pub fn (t &Table) selected() int
Purpose
Get or test the currently selected index, node, or state.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
int — a value of this type
(&Table) sort_column
pub fn (t &Table) sort_column() int
Purpose
Operation on &Table: sort column.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
int — a value of this type
(&Table) sort_descending
pub fn (t &Table) sort_descending() bool
Purpose
Operation on &Table: sort descending.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
bool — true or false
(&Table) scroll_offset
pub fn (t &Table) scroll_offset() f64
Purpose
Operation on &Table: scroll offset.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
f64 — a value of this type
(&Table) needs_paint
pub fn (t &Table) needs_paint() bool
Purpose
Return whether the control needs repainting; call painted after painting to clear the flag.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
bool — true or false
($&Table) painted
pub fn (t $&Table) painted()
Purpose
Acknowledge the painted frame and clear the dirty flag; this is not a query.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&Table) is_selectable
pub fn (t &Table) is_selectable() bool
Purpose
Operation on &Table: whether it is selectable.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
bool — true or false
($&Table) set_selectable
pub fn (t $&Table) set_selectable(selectable bool)
Purpose
Operation on $&Table: set selectable.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
selectable bool- selectable (bool)
Returns
This call does not return a value.
($&Table) set_viewport
pub fn (t $&Table) set_viewport(viewport &layout.Rect)
Purpose
Operation on $&Table: set viewport.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
viewport &layout.Rect- viewport (read-only borrow; caller keeps the original; type &layout.Rect)
Returns
This call does not return a value.
(&Table) cursor
pub fn (t &Table) cursor() int
Purpose
Execute cursor on &Table.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
int — a value of this type
(&Table) is_enabled
pub fn (t &Table) is_enabled() bool
Purpose
Return whether the control is currently enabled.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
bool — true or false
(&Table) is_focused
pub fn (t &Table) is_focused() bool
Purpose
Return whether the control currently has input focus.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
bool — true or false
(&Table) is_read_only
pub fn (t &Table) is_read_only() bool
Purpose
Operation on &Table: whether it is read only.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
bool — true or false
($&Table) cancel
pub fn (t $&Table) cancel()
Purpose
Execute cancel on $&Table.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
Returns
This call does not return a value.
($&Table) set_focus
pub fn (t $&Table) set_focus(focused bool)
Purpose
Operation on $&Table: set focus.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
focused bool- focused (bool)
Returns
This call does not return a value.
($&Table) set_enabled
pub fn (t $&Table) set_enabled(enabled bool)
Purpose
Operation on $&Table: set enabled.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&Table) set_read_only
pub fn (t $&Table) set_read_only(value bool) int
Purpose
Operation on $&Table: set read only. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
value bool- value (bool)
Returns
int — a value of this type
($&Table) set_cell
pub fn (t $&Table) set_cell(row int,column int,text &string) int
Purpose
Operation on $&Table: set cell. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
row int- row (int)
column int- column (int)
text &string- text (read-only borrow; caller keeps the original; type &string)
Returns
int — a value of this type
(&Table) cell
pub fn (t &Table) cell(row int,column int) string
Purpose
Execute cell on &Table. Throws on failure; handle the error or propagate it to the caller.
Parameters
t &Table- The
Table instance used by this call (borrow).
row int- row (int)
column int- column (int)
Returns
string — result string
($&Table) set_rows
pub fn (t $&Table) set_rows(count int) int
Purpose
Operation on $&Table: set rows. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
count int- count (int)
Returns
int — a value of this type
($&Table) set_selected
pub fn (t $&Table) set_selected(index int) int
Purpose
Operation on $&Table: set selected. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
index int- index (int)
Returns
int — a value of this type
($&Table) set_scroll_offset
pub fn (t $&Table) set_scroll_offset(offset f64) int
Purpose
Operation on $&Table: set scroll offset. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
offset f64- offset (f64)
Returns
int — a value of this type
($&Table) set_bounds
pub fn (t $&Table) set_bounds(bounds &layout.Rect) int
Purpose
Operation on $&Table: set bounds. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table 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
(&Table) style_or
pub fn (t &Table) style_or(styles &Styles) ControlStyle
Purpose
Operation on &Table: style or.
Parameters
t &Table- The
Table 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
($&Table) set_style
pub fn (t $&Table) set_style(style &ControlStyle) int
Purpose
Operation on $&Table: set style. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table 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
($&Table) clear_style
pub fn (t $&Table) clear_style()
Purpose
Operation on $&Table: clear style.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
Returns
This call does not return a value.
($&Table) apply_styles
pub fn (t $&Table) 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
t $&Table- The
Table 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
(&Table) row_bounds
pub fn (t &Table) row_bounds(row int) layout.Rect
Purpose
Operation on &Table: row bounds.
Parameters
t &Table- The
Table instance used by this call (borrow).
row int- row (int)
Returns
layout.Rect — a value of this type
(&Table) row_text
pub fn (t &Table) row_text(source_row int) string
Purpose
Operation on &Table: row text.
Parameters
t &Table- The
Table instance used by this call (borrow).
source_row int- source_row (int)
Returns
string — result string
($&Table) input
pub fn (t $&Table) input(input &ui.InputEvent) Action
Purpose
Process routed mouse, keyboard, or touch input events. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table 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.
($&Table) route
pub fn (t $&Table) 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
t $&Table- The
Table 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.
($&Table) event
pub fn (t $&Table) 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
t $&Table- The
Table 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.
($&Table) measure_styled
pub fn (t $&Table) measure_styled(styles &Styles) layout.Size
Purpose
Operation on $&Table: measure styled. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table 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
($&Table) dispose
pub fn (t $&Table) dispose()
Purpose
Release and dispose native resources and underlying handles.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&Table) selected_text
pub fn (t &Table) selected_text() string
Purpose
Operation on &Table: selected text.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
string — result string
(&Table) column_width
pub fn (t &Table) column_width(column int) f64
Purpose
Operation on &Table: column width. Throws on failure; handle the error or propagate it to the caller.
Parameters
t &Table- The
Table instance used by this call (borrow).
column int- column (int)
Returns
f64 — a value of this type
($&Table) set_column_width
pub fn (t $&Table) set_column_width(column int,width f64) int
Purpose
Operation on $&Table: set column width. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
column int- column (int)
width f64- width (f64)
Returns
int — a value of this type
($&Table) set_column_alignment
pub fn (t $&Table) set_column_alignment(column int,alignment f64) int
Purpose
Operation on $&Table: set column alignment. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
column int- column (int)
alignment f64- alignment (f64)
Returns
int — a value of this type
($&Table) set_horizontal_offset
pub fn (t $&Table) set_horizontal_offset(offset f64) int
Purpose
Operation on $&Table: set horizontal offset. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
offset f64- offset (f64)
Returns
int — a value of this type
(&Table) horizontal_offset
pub fn (t &Table) horizontal_offset() f64
Purpose
Operation on &Table: horizontal offset.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
f64 — a value of this type
($&Table) set_status
pub fn (t $&Table) set_status(text &string) int
Purpose
Operation on $&Table: set status. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
text &string- text (read-only borrow; caller keeps the original; type &string)
Returns
int — a value of this type
($&Table) paint_styled
pub fn (t $&Table) paint_styled(frame $&draw.Frame,styles &Styles) int
Purpose
Operation on $&Table: paint styled. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table 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
($&Table) set_column_min_width
pub fn (t $&Table) set_column_min_width(column int,width f64) int
Purpose
Operation on $&Table: set column min width. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
column int- column (int)
width f64- width (f64)
Returns
int — a value of this type
(&Table) row_at
pub fn (t &Table) row_at(view_row int) int
Purpose
Source row indices remain stable while the view is sorted. cell/set_cell address source rows; view_cell and row_at address displayed rows. Throws on failure; handle the error or propagate it to the caller.
Parameters
t &Table- The
Table instance used by this call (borrow).
view_row int- view_row (int)
Returns
int — a value of this type
(&Table) view_row
pub fn (t &Table) view_row(source_row int) int
Purpose
Operation on &Table: view row. Throws on failure; handle the error or propagate it to the caller.
Parameters
t &Table- The
Table instance used by this call (borrow).
source_row int- source_row (int)
Returns
int — a value of this type
(&Table) selected_row
pub fn (t &Table) selected_row() int
Purpose
Operation on &Table: selected row. Throws on failure; handle the error or propagate it to the caller.
Parameters
t &Table- The
Table instance used by this call (borrow).
Returns
int — a value of this type
(&Table) view_cell
pub fn (t &Table) view_cell(row int,column int) string
Purpose
Operation on &Table: view cell. Throws on failure; handle the error or propagate it to the caller.
Parameters
t &Table- The
Table instance used by this call (borrow).
row int- row (int)
column int- column (int)
Returns
string — result string
($&Table) set_selected_row
pub fn (t $&Table) set_selected_row(source_row int) int
Purpose
Operation on $&Table: set selected row. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
source_row int- source_row (int)
Returns
int — a value of this type
($&Table) sort_by
pub fn (t $&Table) sort_by(column int,descending bool) int
Purpose
Operation on $&Table: sort by. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
column int- column (int)
descending bool- descending (bool)
Returns
int — a value of this type
($&Table) refresh_sort
pub fn (t $&Table) refresh_sort() int
Purpose
Operation on $&Table: refresh sort. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
Returns
int — a value of this type
($&Table) set_sort_kind
pub fn (t $&Table) set_sort_kind(column int,kind int) int
Purpose
Operation on $&Table: set sort kind. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
column int- column (int)
kind int- kind tag (int)
Returns
int — a value of this type
($&Table) set_local_sort
pub fn (t $&Table) set_local_sort(enabled bool) int
Purpose
Manual mode keeps header state/events and lets a remote data source own order. Throws on failure; handle the error or propagate it to the caller.
Parameters
t $&Table- The
Table instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
int — a value of this type
Complete native example
Component Workshop · Back to Widgets