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
question
stringThe text on the left of the prompt element.
defaultValue
stringThe text in the center of the prompt element.
placement
PlacementThe placement of the prompt element.
maxInputLength
intThe maximum length of the response.
style
PromptInputStyleThe style of the prompt input.
borderType
BordersTypeThe 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
bordersType
BordersTypeThe 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
defaultValue
stringThe 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
maxLength
intThe 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
placement
PlacementThe 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
question
stringThe 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
selector
charThe 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
style
PromptInputStyleThe new style of the prompt input.
Remarks
For more information, consider visiting the documentation available here.