AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
24.77k stars 2.15k forks source link

Input Method Editor events for TextBox #6490

Open maxkatz6 opened 2 years ago

maxkatz6 commented 2 years ago

https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.textbox.textcompositionchanged?view=winrt-20348 https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.textbox.textcompositionended?view=winrt-20348 https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.textbox.textcompositionstarted?view=winrt-20348

Text composition events occur in the following order:

After the TextCompositionStarted event, the TextChanging > TextChanged > TextCompositionChanged event cycle can occur multiple times before the TextCompositionEnded event occurs.

kekekeks commented 2 years ago

I'm not sure how well that would play with iOS IME API. Or any non-windows IME API.

There is a common concept of non-commited (preedit) text that's displayed after the current caret. Said text is ephemeral and shouldn't be passed to the application until the input method tells us to do so.

iOS might also want us to change arbitrary chunks of text for its auto-correction system to work properly.

robloo commented 2 years ago

TextChanged

Implement TextChanged event for TextBox #418

robloo commented 2 years ago

@maxkatz6 @kekekeks @danwalmsley What is the latest thinking for this issue? I'm going to need these sorts of events soon.

If there are no objections/roadblocks I will plan to implement at least TextChanged. That is required for a number of cases on my end and is very helpful if there is no binding being done. If TextChanging doesn't look too complicated I might attempt that as well.

kekekeks commented 2 years ago

It should be OK to have TextChanged/TextChanging as long as they don't see any uncommited text. Makes implementation more straightforward too.