Browse Source

Attempt to sync caret and surroundingText

pull/8963/head
Benedikt Stebner 3 years ago
parent
commit
5aadbe210c
  1. 16
      src/Web/Avalonia.Web.Blazor/AvaloniaView.razor.cs
  2. 5
      src/Web/Avalonia.Web.Blazor/Interop/InputHelperInterop.cs

16
src/Web/Avalonia.Web.Blazor/AvaloniaView.razor.cs

@ -349,12 +349,12 @@ namespace Avalonia.Web.Blazor
IsComposing = true; IsComposing = true;
break; break;
case WebCompositionEventArgs.WebCompositionEventType.Update: case WebCompositionEventArgs.WebCompositionEventType.Update:
_client?.SetPreeditText(e.Data); _client.SetPreeditText(e.Data);
break; break;
case WebCompositionEventArgs.WebCompositionEventType.End: case WebCompositionEventArgs.WebCompositionEventType.End:
IsComposing = false; IsComposing = false;
_client?.SetPreeditText(null); _client.SetPreeditText(null);
_topLevelImpl.RawTextEvent(e.Data); _topLevelImpl.RawTextEvent(e.Data);
break; break;
} }
} }
@ -467,7 +467,7 @@ namespace Avalonia.Web.Blazor
private void SurroundingTextChanged(object? sender, EventArgs e) private void SurroundingTextChanged(object? sender, EventArgs e)
{ {
if(_client != null && IsComposing) if(_client != null)
{ {
var surroundingText = _client.SurroundingText; var surroundingText = _client.SurroundingText;
@ -480,6 +480,14 @@ namespace Avalonia.Web.Blazor
var bounds = new PixelRect((int)rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height); var bounds = new PixelRect((int)rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height);
_inputHelper?.SetBounds(bounds); _inputHelper?.SetBounds(bounds);
if (_client != null && _client.SupportsSurroundingText && !IsComposing)
{
var surroundingText = _client.SurroundingText;
_inputHelper?.SetSurroundingText(surroundingText.Text, surroundingText.AnchorOffset, surroundingText.CursorOffset);
}
_inputHelper?.Focus(); _inputHelper?.Focus();
} }

5
src/Web/Avalonia.Web.Blazor/Interop/InputHelperInterop.cs

@ -91,11 +91,6 @@ namespace Avalonia.Web.Blazor.Interop
var args = new WebInputEventArgs(type, data); var args = new WebInputEventArgs(type, data);
InputEvent?.Invoke(this, args); InputEvent?.Invoke(this, args);
if (args.Handled)
{
SetSurroundingText("", 0, 0);
}
} }
public void Clear() => _module.Invoke(ClearSymbol, _inputElement); public void Clear() => _module.Invoke(ClearSymbol, _inputElement);

Loading…
Cancel
Save