Class InlineButtonWidget
A reusable button widget. It carries a label, the DialogResultKind it produces when
activated, and an enabled state; it renders itself for the focused/unfocused/disabled states.
A single button is primarily a value/rendering widget — navigation and activation across a row of
buttons live in InlineButtonGroupWidget.
public sealed class InlineButtonWidget : InlineWidget, ICliRenderable
- Inheritance
-
InlineButtonWidget
- Implements
- Inherited Members
Remarks
The selected button renders textual markers (
[▸ Yes ◂]) so the selection is visible without
relying on colour; an unselected button keeps the same width ([ No ]). Selection and group
focus are independent: a selected button keeps its markers whether or not its group has focus —
group focus only changes the selected button's background (active vs muted).Constructors
InlineButtonWidget(ICliAppShell, string, DialogResultKind, bool)
Creates a button that requests a dialog result when activated.
public InlineButtonWidget(ICliAppShell shell, string label, DialogResultKind result, bool enabled = true)
Parameters
shellICliAppShell- The shell that supplies the theme.
labelstring- The text displayed on the button.
resultDialogResultKind- The dialog result requested when the button is activated.
enabledbool- Whether the button can be activated.
Properties
Enabled
Whether the button can be activated.
public bool Enabled { get; set; }
Property Value
Focusable
Whether the widget can receive focus. Non-focusable widgets are skipped by focus traversal.
public override bool Focusable { get; }
Property Value
GroupFocused
Whether the owning button group currently has focus. Set by InlineButtonGroupWidget.
It only affects the selected button's background (active vs inactive); it never hides the
selection markers. HasFocus carries the independent "is the selected
button" concept that drives the markers.
public bool GroupFocused { get; set; }
Property Value
Label
The text displayed on the button.
public string Label { get; }
Property Value
Result
The dialog result requested when the button is activated.
public DialogResultKind Result { get; }
Property Value
Methods
Activate()
Activates the button. An enabled button requests its Result; a disabled button
is still considered handled but produces no result, so the host does not fall back to Enter.
public InlineKeyResult Activate()
Returns
HandleKey(KeyEvent)
Handles a key. Returns whether it was consumed and any requested dialog result.
public override InlineKeyResult HandleKey(KeyEvent key)
Parameters
keyKeyEvent
Returns
ToGrid()
Converts the component into a grid for measurement and rendering.
public override CliGrid ToGrid()