Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Mosaic_ui.Select
Vertical list selector with optional descriptions.
Vertical list selector with optional descriptions.
A focusable, keyboard-navigable list where exactly one item is highlighted at a time. Each item has a label and an optional description. The widget automatically scrolls to keep the selected item centered in the viewport; rendering is buffered.
Keyboard
Up / Down — move selection (Shift for fast scroll by set_fast_scroll_step items).
j / k — move selection by one item.
Enter / KP_enter — activate the current selection (fires the set_on_activate callback).
Mouse
Left click — select the item under the cursor.
Scroll wheel — navigate up or down by one item.
Scroll behaviour
The viewport displays as many items as fit within the available height. When an item is selected the view scrolls to center it. The set_show_scroll_indicator option displays a proportional position indicator in the rightmost column.
set_options t items replaces the item list. The selection index is clamped to the new valid range. Does not fire the set_on_change callback. Triggers re-render.
set_selected_index t i moves the selection to index i, clamped to [0;length - 1]. Fires the set_on_change callback when the clamped index differs from the current selection; no-op otherwise.
set_item_spacing t n sets vertical spacing between items in cells. n is clamped to minimum 0. Recalculates layout and triggers re-render when the value changes.
set_wrap_selection t flag enables or disables wrapping to the opposite end when navigating past list boundaries. Triggers re-render when the value changes.
set_description_color t color sets the description text color.
val set_selected_description_color : t->Ansi.Color.t-> unit
set_selected_description_color t color sets the selected item description text color.
Callbacks
val set_on_change : t->(int -> unit) option-> unit
set_on_change t callback registers a callback fired when the selected index changes. The callback receives the new index. Pass None to clear. See set_selected_index.
val set_on_activate : t->(int -> unit) option-> unit
set_on_activate t callback registers a callback fired when the current item is activated (Enter or KP_enter). The callback receives the activated item index. Pass None to clear.