using Avalonia.Interactivity; namespace Avalonia.Input.TextInput; public abstract class PluggableTextInputMethod { internal TextInputMethodAdapter Adapter { get; } public PluggableTextInputMethod() { Adapter = new(this); } public virtual void SetClient(TextInputMethodClient? client) { } public virtual void SetOptions(TextInputOptions options) { } internal class TextInputMethodAdapter(PluggableTextInputMethod method) : ITextInputMethodImpl { public void SetClient(TextInputMethodClient? client) { method.SetClient(client); } public void SetCursorRect(Rect rect) { // No-op } public void SetOptions(TextInputOptions options) => method.SetOptions(options); public void Reset() { // Implementations should be subscribing to reset event manually } } /// /// Defines the event. /// public static readonly RoutedEvent TextInputMethodRequestedEvent = RoutedEvent.Register( nameof(PluggableTextInputMethodRequestedEventArgs), RoutingStrategies.Tunnel | RoutingStrategies.Bubble); } public class PluggableTextInputMethodRequestedEventArgs : RoutedEventArgs { /// /// Set this property to a valid pluggable text input method to enable its usage with the input system /// public PluggableTextInputMethod? InputMethod { get; set; } }