You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The settings window is declared as `null` here and assigned in Step 3 — the click handler captures it by reference.
59
+
The settings window is declared as `null` here and assigned in Step 5 — the click handler captures it by reference.
59
60
60
-
## Step 3: Create the settings window and NavigationView
61
+
## Step 3: Create the settings window
61
62
62
-
Create the settings window and add a `NavigationView`that fills it — the nav pane is on the left, the content panel on the right.
63
+
Create the settings window. The `NavigationView`will be added to it in Step 5 once all pages are defined inline.
63
64
64
65
```csharp
65
66
settingsWindow=newWindowBuilder(windowSystem)
66
67
.WithTitle("Settings")
67
68
.WithSize(70, 22)
68
69
.Centered()
69
70
.Build();
70
-
71
-
varnav=newNavigationView
72
-
{
73
-
PaneHeader="[bold]Settings[/]",
74
-
VerticalAlignment=VerticalAlignment.Fill
75
-
};
76
-
settingsWindow.AddControl(nav);
77
71
```
78
72
79
-
The `NavigationView` has two zones: a narrow pane on the left for nav items, and a content panel on the right. You'll populate both in the next two steps.
80
-
81
-
## Step 4: Add navigation items
73
+
## Step 4: Declare sliders before the NavigationView builder
82
74
83
-
Each `NavigationItem` represents a page — first argument is the display name, second is an optional icon.
75
+
The sliders must be declared outside the `NavigationView` builder so that `ValueChanged` handlers can capture them after the builder call. They are added to the Appearance page inline inside `AddItem()`.
`NavigationView` auto-selects the first item on load. You can pass a subtitle as an optional third argument.
83
+
## Step 5: Build the NavigationView with inline page content
91
84
92
-
## Step 5: Populate the Appearance page
93
-
94
-
`SetItemContent` registers a factory — `NavigationView` calls it when the item is selected, passing the content `ScrollablePanelControl` for you to populate.
85
+
`AddItem()` accepts an optional `content:` factory — `NavigationView` calls it when the item is first selected, passing the content `ScrollablePanelControl` for you to populate. Both pages are defined inline here.
95
86
96
87
```csharp
97
-
// Declared outside the factory so we can read them in ValueChanged:
> **Alternative:** Skip `SetItemContent`, subscribe to `nav.SelectedItemChanged`, and manipulate `nav.ContentPanel` directly — useful when content depends on external state not known at registration time. See [NavigationView reference](../controls/NavigationView.md).
115
+
`NavigationView` auto-selects the first item on load. `.Fill()` sets `VerticalAlignment.Fill` so the nav spans the full window height.
116
+
117
+
Alternatively, subscribe to `nav.SelectedItemChanged` and manipulate `nav.ContentPanel` directly for content that depends on external runtime state.
`GradientBackground` is a record combining a `ColorGradient` and a `GradientDirection`. `ColorGradient.FromColors()` interpolates smoothly between the stops. See [Gradients & Alpha](../GRADIENTS.md) for predefined gradients and more patterns.
142
145
143
-
## Step 7: Populate the General page
144
-
145
-
The General page is a simple form — labels, text inputs, and a checkbox stacked vertically in the content panel.
Form fields are standard controls inside a `ScrollablePanelControl` — no special form container needed.
163
-
164
-
## Step 8: Add a status bar and keyboard shortcuts
146
+
## Step 7: Add a status bar and keyboard shortcuts
165
147
166
148
`StatusBarControl` is display-and-click-only — it shows key hint text but does NOT intercept keyboard events; wire shortcuts separately via `window.PreviewKeyPressed`.
Pressing Esc closes the settings window and returns focus to the main window. Ctrl+S calls `SaveAndClose()` which applies the gradient and closes the window.
191
173
192
-
## Step 9: Open and close the settings window
174
+
## Step 8: Open and close the settings window
193
175
194
176
`windowSystem.AddWindow()` activates the settings window on top; closing it removes it from the stack and returns focus to the main window.
195
177
@@ -221,10 +203,10 @@ using SharpConsoleUI.Rendering;
221
203
vardriver=newNetConsoleDriver(RenderMode.Buffer);
222
204
varwindowSystem=newConsoleWindowSystem(driver);
223
205
224
-
// ── Sliders declared before SetItemContent factories so ValueChanged can capture them ──
0 commit comments