How to cancel user input on textbox input fields? #7741
Unanswered
jschwizer99
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My users would like to cancel user input by pressing
Esc
. They expect that already entered text is reverted if not yet committed byEnter
orTab
.The textbox offers an Undo() method that will restore the last value of the undo/redo stack. However, this is not the functionality I expect for cancel as if the user did not enter any value before
Esc
a prior value is restored. Furthermore, clearing the undo/redo stack isn't a good idea either.I couldn't find any documentation of input canceling on the WinUI / UWP documentation pages.
Based on https://stackoverflow.com/questions/24251356/how-to-make-textbox-lose-its-focus I use the following quite 'hacky' approach triggered on the
PreviewKeyDown
event.Is there a better and more generic approach to achieving input canceling? Of course, a method like Cancel() would be the ideal case. Needless to say that the functionality is not restricted to textbox only.
Are there any plans to offer user input canceling with WinUI input validation?
Beta Was this translation helpful? Give feedback.
All reactions