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

TextInputEventArgs to have ExpectedText property #18477

Open
RolandUI opened this issue Mar 19, 2025 · 2 comments
Open

TextInputEventArgs to have ExpectedText property #18477

RolandUI opened this issue Mar 19, 2025 · 2 comments

Comments

@RolandUI
Copy link
Contributor

Is your feature request related to a problem? Please describe.

From the customer's point of view, it would be brutally useful to know in advance what result is expected by the input.
This would be helpful for designing custom input controls based on TextBox.

As of now, it is still achievable to predict the expected Text by considering the CaretPosition, Selection, Length and so, but I would instead rely on Avalonia devs' solution, which feels saver as you guys definitely know better this than anyone else.

Describe the solution you'd like

using Avalonia.Interactivity;
namespace Avalonia.Input
{
public class TextInputEventArgs : RoutedEventArgs
{
public string? Text { get; set; }
}
}

Add a new ExpectedText string property to TextInputEventArgs, that predicts the final text.

Describe alternatives you've considered

No response

Additional context

No response

@robloo
Copy link
Contributor

robloo commented Mar 22, 2025

It's not clear what you are asking. It sounds to me like you want text prediction features. Usually that comes with input systems and is backed by a reasonably powerful AI. All of that is out of scope for a UI framework.

If my understanding is correct I think this should be closed as out of scope honestly.

@RolandUI
Copy link
Contributor Author

No.

In the case of a TextBox whenever a new character is entered, you will see the OnTextInput even called with a TextInputEventArgs in parameters.

I am talking about the TextInputEventArgs which could have another property called ExpectedText, because as of now the existing Text property stands for the new input that was just entered.

  1. Your TextBox's text is: Avaloni (There is no selection, caret is end the end)
  2. The next character you enter is a.
  3. OnTextInput fires with TextInputEventArgs where Text = "a".

In this case, the ExpectedText property could predict that if the event goes through the final Text in the TextBox is going to be Avalonia.

Why is this helpful? It would be much easier to build custom controls that serve a specific task and are strict on the inputs.

As is said, currently this feature is doable on the customer side (because we are doing it), but it is safe to say that the Avalonia developers can calculate the expected text much better, as they know all to factors that need to be taken into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants