Skip to content

Commit c6fc825

Browse files
committed
docs: add docs for 9 controls, fix broken cross-links
Add source-verified documentation for TreeControl, DropdownControl, MenuControl, CheckboxControl, FigleControl, SpectreRenderableControl, LogViewerControl, ScrollablePanelControl, and HorizontalGridControl — controls that existed in the library but had no docs, leaving dead "See Also" links in sibling control docs. Link all nine from CONTROLS.md (correcting a FigletControl -> FigleControl label typo) and fix a broken anchor in BUILDERS.md (#critical-setup-requirement -> #critical-setup-requirement-linux-only). DocFX now builds with no broken links (0 errors).
1 parent 112ac39 commit c6fc825

11 files changed

Lines changed: 2680 additions & 10 deletions

docs/BUILDERS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ new BarGraphBuilder()
535535

536536
### TerminalBuilder
537537

538-
> **Platform:** Linux only. Requires `PtyShim.RunIfShim(args)` at the start of `Main` — see [TerminalControl](controls/TerminalControl.md#critical-setup-requirement).
538+
> **Platform:** Linux only. Requires `PtyShim.RunIfShim(args)` at the start of `Main` — see [TerminalControl](controls/TerminalControl.md#critical-setup-requirement-linux-only).
539539
540540
```csharp
541541
// Quick open — auto-sized window

docs/CONTROLS.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Controls for user input and interaction.
3535
| Control | Description | Details |
3636
|---------|-------------|---------|
3737
| **[ButtonControl](controls/ButtonControl.md)** | Clickable button with text | Click events, keyboard/mouse support |
38-
| **CheckboxControl** | Toggle checkbox with label | Checked/unchecked state, change events |
38+
| **[CheckboxControl](controls/CheckboxControl.md)** | Toggle checkbox with label | Checked/unchecked state, change events |
3939
| **[DatePickerControl](controls/DatePickerControl.md)** | Locale-aware date picker | Segmented editing, calendar popup, min/max dates |
4040
| **[PromptControl](controls/PromptControl.md)** | Single-line text input | Enter key events, input validation, max length |
4141
| **[TimePickerControl](controls/TimePickerControl.md)** | Locale-aware time picker | 12h/24h modes, seconds toggle, min/max times |
@@ -51,9 +51,9 @@ Controls for selecting items from lists or hierarchies.
5151
|---------|-------------|---------|
5252
| **[ListControl](controls/ListControl.md)** | Scrollable list with selection | Single selection, item activation, keyboard navigation |
5353
| **[TableControl](controls/TableControl.md)** | Interactive data grid | Virtual data, sorting, filtering (AND/OR), inline editing, multi-select, cell navigation, scrollbars |
54-
| **TreeControl** | Hierarchical tree view | Expand/collapse nodes, selection, keyboard navigation |
55-
| **DropdownControl** | Dropdown selection list | Click to expand, keyboard navigation, portal rendering |
56-
| **MenuControl** | Menu bar with dropdowns | Horizontal/vertical menus, submenus, separators, keyboard shortcuts |
54+
| **[TreeControl](controls/TreeControl.md)** | Hierarchical tree view | Expand/collapse nodes, selection, keyboard navigation |
55+
| **[DropdownControl](controls/DropdownControl.md)** | Dropdown selection list | Click to expand, keyboard navigation, portal rendering |
56+
| **[MenuControl](controls/MenuControl.md)** | Menu bar with dropdowns | Horizontal/vertical menus, submenus, separators, keyboard shortcuts |
5757

5858
## Display Controls
5959

@@ -63,9 +63,9 @@ Controls for displaying formatted content.
6363
|---------|-------------|---------|
6464
| **[MarkupControl](controls/MarkupControl.md)** | Rich text with markup | Colors, bold, italic, links using `[markup]` syntax |
6565
| **[HtmlControl](controls/HtmlControl.md)** | HTML content renderer | Parse & render HTML with images, links, tables, keyboard navigation |
66-
| **FigletControl** | ASCII art text (Figlet) | Large stylized text, multiple fonts |
67-
| **LogViewerControl** | Log message viewer | Auto-scroll, filtering, severity colors |
68-
| **SpectreRenderableControl** | Wrapper for Spectre widgets | Display Tables, Trees, Panels, Charts, etc. |
66+
| **[FigleControl](controls/FigleControl.md)** | ASCII art text (Figlet) | Large stylized text, multiple fonts |
67+
| **[LogViewerControl](controls/LogViewerControl.md)** | Log message viewer | Auto-scroll, filtering, severity colors |
68+
| **[SpectreRenderableControl](controls/SpectreRenderableControl.md)** | Wrapper for Spectre widgets | Display Tables, Trees, Panels, Charts, etc. |
6969
| **PanelControl** | Bordered content panel | Headers, multiple border styles, padding, mouse support |
7070
| **RuleControl** | Horizontal rule/separator | Optional title, colors, horizontal line |
7171
| **SparklineControl** | Time-series sparkline graph | Block, braille, or bidirectional modes; borders; titles |
@@ -90,8 +90,8 @@ Controls for organizing other controls.
9090
| Control | Description | Details |
9191
|---------|-------------|---------|
9292
| **ColumnContainer** | Vertical stack container | Stack controls vertically, padding, alignment |
93-
| **ScrollablePanelControl** | Scrollable content area | Vertical scrolling, contains multiple controls |
94-
| **HorizontalGridControl** | Multi-column layout | Variable-width columns, alignment, splitters |
93+
| **[ScrollablePanelControl](controls/ScrollablePanelControl.md)** | Scrollable content area | Vertical scrolling, contains multiple controls |
94+
| **[HorizontalGridControl](controls/HorizontalGridControl.md)** | Multi-column layout | Variable-width columns, alignment, splitters |
9595
| **SplitterControl** | Resizable divider | Drag to resize adjacent columns |
9696
| **[TabControl](controls/TabControl.md)** | Multi-page tab container | Tab headers, keyboard/mouse switching, state preservation |
9797
| **[NavigationView](controls/NavigationView.md)** | Sidebar navigation + content area | WinUI-inspired nav pane, responsive display modes (Expanded/Compact/Minimal), content factories, gradient-transparent |

docs/controls/CheckboxControl.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# CheckboxControl
2+
3+
Toggleable checkbox control with a label, checked/unchecked state, and keyboard/mouse support.
4+
5+
## Overview
6+
7+
CheckboxControl displays a label next to a `[ ]` / `[X]` indicator and toggles its checked state when activated. It responds to keyboard (Space/Enter) and mouse clicks, and fires a `CheckedChanged` event whenever the state flips.
8+
9+
The checked and unchecked indicator characters are fully customizable, so the control can render anything from a classic `X` to a check mark (``), a dot (``), or any other single visible character. Colors for the normal, focused, and disabled states, as well as the checkmark itself, can be overridden or left to inherit from the active theme.
10+
11+
The control measures itself to a single row sized to ` [X] Label `, but it also honors a fixed `Width` and `HorizontalAlignment` (including `Stretch`) when laid out inside containers.
12+
13+
See also: [ButtonControl](ButtonControl.md)
14+
15+
## Quick Start
16+
17+
```csharp
18+
var checkbox = Controls.Checkbox("Enable notifications")
19+
.Checked(true)
20+
.OnCheckedChanged((sender, isChecked) =>
21+
{
22+
// React to the new state
23+
})
24+
.Build();
25+
26+
window.AddControl(checkbox);
27+
```
28+
29+
## Builder API
30+
31+
### Content
32+
33+
```csharp
34+
Controls.Checkbox("Label") // Factory sets the initial label
35+
.WithLabel("Enable feature") // Override the label text
36+
.Checked(true) // Set initial checked state (default: true when called)
37+
.Checked(false); // Explicitly start unchecked
38+
```
39+
40+
### Indicator Characters
41+
42+
```csharp
43+
Controls.Checkbox("Custom marks")
44+
.WithCheckedCharacter("") // Character shown when checked (default "X")
45+
.WithUncheckedCharacter("·") // Character shown when unchecked (default " ")
46+
.WithCheckmark("", "·"); // Set both at once (unchecked defaults to " ")
47+
```
48+
49+
### Layout
50+
51+
```csharp
52+
Controls.Checkbox("Label")
53+
.WithWidth(30) // Fixed width
54+
.WithAlignment(HorizontalAlignment.Center) // Horizontal alignment
55+
.WithVerticalAlignment(VerticalAlignment.Top)
56+
.WithMargin(1) // Uniform margin
57+
.WithMargin(1, 0, 1, 0) // left, top, right, bottom
58+
.Visible(true)
59+
.StickyTop() // Stick to top of window
60+
.StickyBottom() // Stick to bottom of window
61+
.WithStickyPosition(StickyPosition.None);
62+
```
63+
64+
### Identity
65+
66+
```csharp
67+
Controls.Checkbox("Label")
68+
.WithName("myCheckbox") // Name for FindControl<CheckboxControl>("myCheckbox")
69+
.WithTag(myData); // Arbitrary tag object
70+
```
71+
72+
### Events
73+
74+
```csharp
75+
Controls.Checkbox("Label")
76+
.OnCheckedChanged((sender, isChecked) => { /* ... */ })
77+
.OnCheckedChanged((sender, isChecked, window) => { /* window-aware */ })
78+
.OnGotFocus((sender, e) => { /* ... */ })
79+
.OnGotFocus((sender, e, window) => { /* window-aware */ })
80+
.OnLostFocus((sender, e) => { /* ... */ })
81+
.OnLostFocus((sender, e, window) => { /* window-aware */ });
82+
```
83+
84+
## Properties
85+
86+
| Property | Type | Default | Description |
87+
|----------|------|---------|-------------|
88+
| `Checked` | `bool` | `false` | The checked state; setting it fires `CheckedChanged` |
89+
| `Label` | `string` | `"Checkbox"` | Text displayed next to the checkbox |
90+
| `CheckedCharacter` | `string` | `"X"` | Character shown inside the box when checked (empty/null falls back to default) |
91+
| `UncheckedCharacter` | `string` | `" "` | Character shown inside the box when unchecked (empty/null falls back to default) |
92+
| `IsEnabled` | `bool` | `true` | Whether the checkbox can be interacted with |
93+
| `Width` | `int?` | `null` | Fixed width (auto-sized to content if null) |
94+
| `BackgroundColor` | `Color?` | `null` | Background color in the normal state (uses theme if null) |
95+
| `ForegroundColor` | `Color` | theme `ButtonForegroundColor` / `Color.White` | Text color in the normal state |
96+
| `FocusedBackgroundColor` | `Color?` | `null` | Background color when focused (uses theme if null) |
97+
| `FocusedForegroundColor` | `Color` | theme `ButtonFocusedForegroundColor` / `Color.White` | Text color when focused |
98+
| `DisabledBackgroundColor` | `Color?` | `null` | Background color when disabled (uses theme if null) |
99+
| `DisabledForegroundColor` | `Color` | theme `ButtonDisabledForegroundColor` / `Color.DarkSlateGray1` | Text color when disabled |
100+
| `CheckmarkColor` | `Color` | theme `ButtonFocusedForegroundColor` / `Color.Cyan1` | Color of the checkmark character when checked |
101+
| `HasFocus` | `bool` | `false` | Whether the checkbox currently has keyboard focus |
102+
| `CanReceiveFocus` | `bool` | `true` | Whether the checkbox can receive focus (mirrors `IsEnabled`) |
103+
| `WantsMouseEvents` | `bool` | `true` | Whether the checkbox wants mouse events (mirrors `IsEnabled`) |
104+
| `CanFocusWithMouse` | `bool` | `true` | Whether a mouse click can focus the checkbox (mirrors `IsEnabled`) |
105+
106+
## Events
107+
108+
| Event | Arguments | Description |
109+
|-------|-----------|-------------|
110+
| `CheckedChanged` | `EventHandler<bool>` | Fired when the checked state changes; argument is the new state |
111+
| `CheckedChangedAsync` | `AsyncEventHandler<bool>` | Async counterpart of `CheckedChanged` |
112+
| `MouseClick` | `EventHandler<MouseEventArgs>` | Fired when the checkbox is left-clicked |
113+
| `MouseDoubleClick` | `EventHandler<MouseEventArgs>` | Fired when the checkbox is double-clicked |
114+
| `MouseRightClick` | `EventHandler<MouseEventArgs>` | Fired when the checkbox is right-clicked |
115+
| `MouseEnter` | `EventHandler<MouseEventArgs>` | Fired when the mouse enters the checkbox area |
116+
| `MouseLeave` | `EventHandler<MouseEventArgs>` | Fired when the mouse leaves the checkbox area |
117+
| `MouseMove` | `EventHandler<MouseEventArgs>` | Fired when the mouse moves over the checkbox |
118+
| `GotFocus` | `EventHandler` | Fired when the checkbox receives focus |
119+
| `LostFocus` | `EventHandler` | Fired when the checkbox loses focus |
120+
121+
## Keyboard Support
122+
123+
| Key | Action |
124+
|-----|--------|
125+
| **Space** | Toggle checked state |
126+
| **Enter** | Toggle checked state |
127+
| **Tab** | Move focus to next control |
128+
| **Shift+Tab** | Move focus to previous control |
129+
130+
Keys are only processed while the checkbox is enabled and focused.
131+
132+
## Mouse Support
133+
134+
| Action | Result |
135+
|--------|--------|
136+
| **Left Click** | Toggle checked state and fire `MouseClick` |
137+
| **Double Click** | Fire `MouseDoubleClick` (does not toggle again) |
138+
| **Right Click** | Fire `MouseRightClick` |
139+
| **Click** | Give the checkbox keyboard focus |
140+
| **Enter / Leave** | Fire `MouseEnter` / `MouseLeave` |
141+
142+
Mouse events are only processed when enabled, and clicks in the control's margin area are ignored.
143+
144+
## Examples
145+
146+
### Simple Checkbox
147+
148+
```csharp
149+
window.AddControl(
150+
Controls.Checkbox("Enable notifications")
151+
.Checked(true)
152+
.Build()
153+
);
154+
```
155+
156+
### Reacting to State Changes
157+
158+
```csharp
159+
window.AddControl(
160+
Controls.Checkbox("Auto-save on exit")
161+
.OnCheckedChanged((sender, isChecked) =>
162+
{
163+
windowSystem.NotificationStateService.ShowNotification(
164+
"Auto-save",
165+
isChecked ? "Enabled" : "Disabled",
166+
NotificationSeverity.Info
167+
);
168+
})
169+
.Build()
170+
);
171+
```
172+
173+
### Custom Checkmark Characters
174+
175+
```csharp
176+
window.AddControl(
177+
Controls.Checkbox("Custom marks")
178+
.WithCheckmark("", "·")
179+
.Checked(true)
180+
.Build()
181+
);
182+
```
183+
184+
### Reading State From Another Control
185+
186+
```csharp
187+
window.AddControl(
188+
Controls.Checkbox("Animate background gradient")
189+
.WithName("animToggle")
190+
.Checked(true)
191+
.Build()
192+
);
193+
194+
// Elsewhere (e.g. an async window thread):
195+
var toggle = window.FindControl<CheckboxControl>("animToggle");
196+
if (toggle?.Checked == true)
197+
{
198+
// run the animation
199+
}
200+
```
201+
202+
### Two-Way Data Binding
203+
204+
```csharp
205+
var enabledCheckbox = Controls.Checkbox("Monitoring Enabled")
206+
.Build();
207+
208+
// Keep the view model and the checkbox in sync both ways
209+
enabledCheckbox.BindTwoWay(vm, v => v.MonitoringEnabled, c => c.Checked);
210+
211+
window.AddControl(enabledCheckbox);
212+
```
213+
214+
### Settings Panel
215+
216+
```csharp
217+
panel.AddControl(Controls.Checkbox("Enable notifications").Checked(true).Build());
218+
panel.AddControl(Controls.Checkbox("Auto-save on exit").Checked(true).Build());
219+
panel.AddControl(Controls.Checkbox("Show status bar").Build());
220+
panel.AddControl(Controls.Checkbox("Enable telemetry").Build());
221+
```
222+
223+
## Best Practices
224+
225+
1. **Use clear labels**: The label should describe the option being toggled ("Enable notifications", not "Notifications?").
226+
2. **Set the initial state explicitly**: Use `.Checked(true)` for options that should default to on so the UI matches your model.
227+
3. **Prefer `CheckedChanged` over polling**: React to state changes through the event rather than reading `Checked` on a timer.
228+
4. **Bind to your model**: Use `BindTwoWay` to keep a view-model property and the checkbox in sync without manual event wiring.
229+
5. **Name checkboxes you read later**: Use `.WithName(...)` so you can retrieve state with `FindControl<CheckboxControl>(...)`.
230+
6. **Customize marks for clarity**: Use `WithCheckmark` to match your visual style, but keep characters single-width for clean alignment.
231+
232+
## See Also
233+
234+
- [ButtonControl](ButtonControl.md) - For click actions
235+
- [PromptControl](PromptControl.md) - For text input
236+
237+
---
238+
239+
[Back to Controls](../CONTROLS.md) | [Back to Main Documentation](../../README.md)

0 commit comments

Comments
 (0)