Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to cancel input during Prompt() #1392

Open
kentico-ericd opened this issue Dec 1, 2023 · 2 comments
Open

Allow user to cancel input during Prompt() #1392

kentico-ericd opened this issue Dec 1, 2023 · 2 comments
Labels
feature ⭐ top feature Top feature request. ⭐ top issue Top issue.

Comments

@kentico-ericd
Copy link

kentico-ericd commented Dec 1, 2023

Is your feature request related to a problem? Please describe.
When requesting user input multiple times, it would be nice to provide a way for the user to return to previous steps in case they've entered some wrong information.

Describe the solution you'd like
We could capture the ESC keypress during AnsiConsole.Prompt and set a variable, e.g. AnsiConsole.Prompt(prompt, out var cancelled) to indicate the user pressed escape. Or, the return value of AnsiConsole.Prompt could be null if the input was cancelled.

Describe alternatives you've considered
There are some incomplete code samples here that I've tried, but there are multiple issues with the code such as exceptions and formatting problems. It would be great if this was a native solution in Spectre.Console.


Please upvote 👍 this issue if you are interested in it.

@abpiskunov
Copy link

I did request some thing similar last year, but it did not go anywhere unfortunately. It would be nice to make keyboard handling extensible to support something like this:

image

where we could tell prompt to listen for several keys depending on user scenario, like Esc or Ctrl+C or q for exit, back key or help key etc.

@schlechtOptimiziert
Copy link

Yeah, cancel would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⭐ top feature Top feature request. ⭐ top issue Top issue.
Projects
Status: Todo 🕑
Development

No branches or pull requests

4 participants