Add spell checker for message input box

This commit is contained in:
Stone_Red
2026-07-28 23:42:57 +02:00
parent ee3beaca2f
commit 3345b06322
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -23,6 +23,7 @@
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets> <IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets> <PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="GHSoftware.Avalonia.SpellChecker.Avalonia11" Version="0.3.3" />
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" /> <PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
<PackageReference Include="NetCoreAudio" Version="2.0.1" /> <PackageReference Include="NetCoreAudio" Version="2.0.1" />
<PackageReference Include="OsNotifications" Version="1.1.5" /> <PackageReference Include="OsNotifications" Version="1.1.5" />
@@ -3,6 +3,7 @@ using Avalonia.Input;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using Avalonia.SpellChecker;
using Decho.Models; using Decho.Models;
using Decho.ViewModels; using Decho.ViewModels;
@@ -15,6 +16,8 @@ namespace Decho.Views;
public partial class MessageComposerView : UserControl public partial class MessageComposerView : UserControl
{ {
private readonly TextBoxSpellChecker _spellChecker;
public MessageComposerView() public MessageComposerView()
{ {
InitializeComponent(); InitializeComponent();
@@ -25,6 +28,9 @@ public partial class MessageComposerView : UserControl
// Intercept Enter before the TextBox processes it (AcceptsReturn=True would insert a newline) // Intercept Enter before the TextBox processes it (AcceptsReturn=True would insert a newline)
MessageTextBox.AddHandler(InputElement.KeyDownEvent, OnTextBoxTunnelingKeyDown, RoutingStrategies.Tunnel); MessageTextBox.AddHandler(InputElement.KeyDownEvent, OnTextBoxTunnelingKeyDown, RoutingStrategies.Tunnel);
_spellChecker = new TextBoxSpellChecker(SpellCheckerConfig.Create("en_GB"));
_spellChecker.Initialize(MessageTextBox);
} }
private void OnDataContextChanged(object? sender, EventArgs e) private void OnDataContextChanged(object? sender, EventArgs e)