A scrollable list widget that displays items and highlights the selected one.
More...
|
|
| List () |
| | Object-initializer constructor; all properties default.
|
| | List (IReadOnlyList< string > items, int selectedIndex=0, Style? style=null, Style? selectedItemStyle=null, int paddingLeft=1, int paddingRight=0, int scrollOffset=0) |
| | Positional constructor for inline usage.
|
|
void | OnKeyEvent (KeyMsg key, Action< IMsg > dispatch) |
| | Called by the runtime when a key is pressed and this widget has focus.Call dispatch to inject a custom IMsg into the event loop.
|
|
void | Render (IRenderContext ctx) |
| | Render this widget into the provided context.The context carries the allocated region, theme, and color profile. Implementations MUST NOT write outside ctx.Region.
|
|
| static int | ComputeScrollOffset (int selectedIndex, int viewportHeight, int currentScrollOffset) |
| | Computes a new ScrollOffset that keeps selectedIndex within the visible viewport.
|
|
|
bool | HasFocus [get, set] |
| | True when this widget holds keyboard focus.
|
|
SizeConstraint | Height = SizeConstraint.Flex(1) [get] |
| | Height constraint used by the layout engine.
|
|
IReadOnlyList< string > | Items = [] [get] |
| | The display strings shown in the list.
|
| int | PaddingLeft = 1 [get] |
| | Number of blank columns inserted to the left of each item's text.
|
| int | PaddingRight = 0 [get] |
| | Number of blank columns reserved to the right of each item's text.
|
| int | ScrollOffset [get] |
| | Zero-based index of the first item rendered in the viewport.
|
|
int | SelectedIndex [get] |
| | Zero-based index of the currently highlighted item.
|
|
Style | SelectedItemStyle = Style.Default.Reverse(true) [get] |
| | Visual style applied to the highlighted row. Defaults to reverse-video.
|
|
Style | Style = Style.Default [get] |
| | Visual style for unselected rows. Inherits theme base style when no properties set.
|
|
SizeConstraint | Width = SizeConstraint.Flex(1) [get] |
| | Width constraint used by the layout engine.
|
A scrollable list widget that displays items and highlights the selected one.
Dispatches ListItemSelectedMsg when the user presses Enter.
◆ List()
| ConsoleForge.Widgets.List.List |
( |
IReadOnlyList< string > | items, |
|
|
int | selectedIndex = 0, |
|
|
Style? | style = null, |
|
|
Style? | selectedItemStyle = null, |
|
|
int | paddingLeft = 1, |
|
|
int | paddingRight = 0, |
|
|
int | scrollOffset = 0 ) |
Positional constructor for inline usage.
- Parameters
-
| items | Display strings to show. |
| selectedIndex | Initially highlighted row index (clamped). |
| style | Optional style for unselected rows. |
| selectedItemStyle | Optional style for the highlighted row. |
| paddingLeft | Blank columns inserted to the left of each item's text. Provides breathing room when the list is placed inside a BorderBox. Defaults to 1. |
| paddingRight | Blank columns reserved to the right of each item's text. Defaults to 0. |
| scrollOffset | First visible item index. Defaults to 0. |
◆ ComputeScrollOffset()
| int ConsoleForge.Widgets.List.ComputeScrollOffset |
( |
int | selectedIndex, |
|
|
int | viewportHeight, |
|
|
int | currentScrollOffset ) |
|
static |
Computes a new ScrollOffset that keeps selectedIndex within the visible viewport.
Call this from your model's Update handler when processing ListSelectionChangedMsg.
- Parameters
-
| selectedIndex | The newly selected item index. |
| viewportHeight | Number of visible rows in the List's region. |
| currentScrollOffset | Current ScrollOffset. |
◆ PaddingLeft
| int ConsoleForge.Widgets.List.PaddingLeft = 1 |
|
get |
Number of blank columns inserted to the left of each item's text.
Provides breathing room when the list is placed inside a BorderBox. Defaults to 1.
◆ PaddingRight
| int ConsoleForge.Widgets.List.PaddingRight = 0 |
|
get |
Number of blank columns reserved to the right of each item's text.
Defaults to 0.
◆ ScrollOffset
| int ConsoleForge.Widgets.List.ScrollOffset |
|
get |
Zero-based index of the first item rendered in the viewport.
Update via ComputeScrollOffset when handling ListSelectionChangedMsg to keep the selection visible.
The documentation for this class was generated from the following file:
- src/ConsoleForge/Widgets/List.cs