PromptPlus

PromptPlus # PromptPlus ## **Switch — Operations** [![NuGet](https://img.shields.io/badge/NuGet-PromptPlus-blue)](https://www.nuget.org/packages/PromptPlus) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![.NET](https://img.shields.io/badge/.NET-8%20%7C%209%20%7C%2010-512BD4)](https://dotnet.microsoft.com/)

← Back to HomeNext: Switch — Styles →


How the Switch control behaves while it is running: keyboard, the two labeled states, history, and the details that matter in real apps.


Anatomy of the control

Enable feature?                          ← prompt
Notifications are enabled                 ← description (optional / dynamic)
 Yes   No                                 ← the two states; the active one is highlighted
Left/Right / Space: toggle  Enter  Esc    ← tooltip (toggle with F1 / Ctrl+F1)

Every region can be recolored — see Styles.


Keyboard

Key Action
Force the state to off, regardless of the current state
Force the state to on, regardless of the current state
Space Toggle — flips the current state to its opposite
Enter Confirm — returns the current state
Esc Abort (when the abort key is enabled) → IsAborted == true, Content == null
F1 Cycle tooltip content
Ctrl+F1 Show / hide the tooltip

⚠️ / are absolute, not relative — always lands on off and always lands on on, even if you’re already there. Only Space actually flips the current value. There is also no Tab/Shift+Tab binding on this control.


States & labels


History

When EnableHistory(filename, …) is set:

You can also manage a history store directly with PromptPlus.Controls.History(filename) — add, save, or remove entries programmatically (used in the samples to seed reproducible data).


Options that change behavior

Set per instance via Options(...), or globally on PromptPlus.Config:

Option Effect on Switch
EnabledAbortKey(false) Removes Esc — the user must confirm
HideAfterFinish(true) Erases the toggle after confirm — the whole control is erased, not just the interactive part
HideOnAbort(true) Erases the toggle after Esc
ShowTooltip(false) Hides the keyboard hint line
Description(...) Overrides the description text

The global PromptPlus.Config.SwitchWidth influences how the toggle is laid out.


Edge cases & gotchas


See also