UXTableDelegate
UXTableDelegate is how a UXTableView
tells you the selection changed. It has one optional method.
#use <UXKit> // or #import "UXTableView.xc"Overview
Section titled “Overview”protocol UXTableDelegate { optional void tableSelectionDidChange(UXTableView* t, i32 row);}Because the method is optional, a table with no delegate is fully
functional. It draws, scrolls and selects. Add a delegate when you need to
know what was selected.
void tableSelectionDidChange(UXTableView* t, i32 row) { if (row < 0) { status.setText((u8*)"nothing selected"); return; } status.setText(((Track* ?)tracks.get((u16)row)).name);}Topics
Section titled “Topics”tableSelectionDidChange
Section titled “tableSelectionDidChange”optional void tableSelectionDidChange(UXTableView* t, i32 row)The selection came to rest at row.
row < 0 means nothing is selected. The table sends this when the user
clicks away and after a reload drops the previous selection, so handle it as a
normal state.
The table is passed in, so one delegate can serve several tables.
Multiple selection is not this method
Section titled “Multiple selection is not this method”With setAllowsMultipleSelection(true) the delegate still reports a single
anchor row, because a delegate callback carries one row. The full selection
arrives as a UXIndexSet on the
UXEventSelected event.
There are two reasons for the split:
- An anchor alone replays as one row however many were chosen, so a recording of a multi-select would be wrong.
- On a backend whose table is a native list, the click never reaches the
toolkit. It arrives as
WM_NOTIFY/LVN_ITEMCHANGED, so the event is the only record of what happened.
Use this method for “the user picked a row”. Read the event’s index set when you need the whole selection.
See also
Section titled “See also”- Tables, outlines and data sources: the working program
UXTableDataSource: the required halfUXIndexSet: what a multi-selection isUXEvent:UXEventSelected, and why it is an outcome rather than input