-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
With DisplayPromptAsync you can include an initialValue to be showed in the dialog shown.
I'd like a feature for this initialValue to be preselected so it is ready to be overwritten with a simple input, instead of the user needs to clear the field first.
Also requested on StackOverflow by another user.
Public API Changes
Not sure if I fill out this field correctly, but just add another optional parameter next to string initialValue named e.g. bool preselectInitialValue = false. In body, if new parameter is true, select all of the text in tne Entry. Also test scenariou where user enters input very quickly after rendering, as the .Text apparently can be null.
public Task<string> DisplayPromptAsync(
string title,
string message,
string accept = "OK",
string cancel = "Cancel",
string placeholder = null,
int maxLength = -1,
Keyboard keyboard = null,
string initialValue = "",
bool preselectInitialValue = false)
{
(...)
if (preselectInitialValue && !string.isNullOrEmpty(initialValue)) {
x.SelectionLength = x.Text != null ? x.Text.Length : 0;
}
(...)
}
Intended Use-Case
Example:
User needs to enter number of copies to print. Most often this is 1, so that is set as initialValue. If user presses "2" to print two copies, it now says "12". If as requested, we could indicate the initialValue should be preselected (quite a normal UI functionality), then when user presses "2", it would overwrite "1" and instead the value entered would be "2".