Class Prompt
- Namespace
- ConsoleAppVisuals.InteractiveElements
- Assembly
- ConsoleAppVisuals.dll
The Prompt is an interactive element that allows the user to input a string response.
public class Prompt : InteractiveElement<string>
- Inheritance
-
Prompt
- Inherited Members
Remarks
For more information, consider visiting the documentation available here.
Constructors
Prompt(string, string?, Placement, int, PromptInputStyle, BordersType)
The Prompt is an interactive element that allows the user to input a string response.
public Prompt(string question, string? defaultValue = null, Placement placement = Placement.TopCenter, int maxInputLength = 12, PromptInputStyle style = PromptInputStyle.Default, BordersType borderType = BordersType.SingleStraight)
Parameters
questionstringThe text on the left of the prompt element.
defaultValuestringThe text in the center of the prompt element.
placementPlacementThe placement of the prompt element.
maxInputLengthintThe maximum length of the response.
stylePromptInputStyleThe style of the prompt input.
borderTypeBordersTypeThe type of border to use for the element.
Remarks
For more information, consider visiting the documentation available here.
Properties
Borders
Gets the borders of the prompt element.
public Borders Borders { get; }
Property Value
BordersType
Gets the border type of the selector.
public BordersType BordersType { get; }
Property Value
DefaultValue
Gets the default value of the response.
public string DefaultValue { get; }
Property Value
Height
Gets the height of the prompt element.
public override int Height { get; }
Property Value
MaxInputLength
Gets the maximum length of the response.
public int MaxInputLength { get; }
Property Value
Placement
Gets the placement of the prompt element.
public override Placement Placement { get; }
Property Value
Question
Gets the question of the prompt element.
public string Question { get; }
Property Value
Selector
Gets the selector of the prompt element.
public char Selector { get; }
Property Value
Style
Gets the style of the prompt input.
public PromptInputStyle Style { get; }
Property Value
Width
Gets the width of the prompt element.
public override int Width { get; }
Property Value
Methods
RenderElementActions()
Defines the actions to perform when the element is called to be rendered on the console.
[Visual]
protected override void RenderElementActions()
UpdateBordersType(BordersType)
Updates the border type of the prompt element.
public void UpdateBordersType(BordersType bordersType)
Parameters
bordersTypeBordersTypeThe new border type of the prompt element.
Remarks
For more information, consider visiting the documentation available here.
UpdateDefaultValue(string?)
Updates the default value of the prompt element.
public void UpdateDefaultValue(string? defaultValue)
Parameters
defaultValuestringThe new default value of the prompt element.
Remarks
For more information, consider visiting the documentation available here.
UpdateMaxLength(int)
Updates the maximum length of the response.
public void UpdateMaxLength(int maxLength)
Parameters
maxLengthintThe new maximum length of the response.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentOutOfRangeException
The maximum length of the response must be greater than 0 and less than the width of the console window.
UpdatePlacement(Placement)
Updates the placement of the prompt element.
public void UpdatePlacement(Placement placement)
Parameters
placementPlacementThe new placement of the prompt element.
Remarks
For more information, consider visiting the documentation available here.
UpdateQuestion(string)
Updates the question of the prompt element.
public void UpdateQuestion(string question)
Parameters
questionstringThe new question of the prompt element.
Remarks
For more information, consider visiting the documentation available here.
UpdateSelector(char)
Updates the selector of the prompt element.
public void UpdateSelector(char selector = '▶')
Parameters
selectorcharThe new selector of the prompt element.
Remarks
For more information, consider visiting the documentation available here.
UpdateStyle(PromptInputStyle)
Updates the style of the prompt input.
public void UpdateStyle(PromptInputStyle style)
Parameters
stylePromptInputStyleThe new style of the prompt input.
Remarks
For more information, consider visiting the documentation available here.