Browse Source

Fix iOS build

feature/ImePreeditText
Benedikt 4 years ago
parent
commit
acecaf7018
  1. 3
      samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj
  2. 19
      src/iOS/Avalonia.iOS/AvaloniaView.Text.cs
  3. 2
      src/iOS/Avalonia.iOS/AvaloniaView.cs

3
samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj

@ -9,6 +9,9 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<!-- <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>-->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CodesignKey>iPhone Developer</CodesignKey>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj" />
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" />

19
src/iOS/Avalonia.iOS/AvaloniaView.Text.cs

@ -13,8 +13,15 @@ namespace Avalonia.iOS;
[Adopts("UIKeyInput")]
public partial class AvaloniaView : ITextInputMethodImpl
{
private ITextInputMethodClient? _currentClient;
private IUITextInputDelegate _inputDelegate;
private ITextInputMethodClient? _client;
class TextInputHandler : UITextInputDelegate
{
}
public ITextInputMethodClient? Client => _client;
public bool IsActive => _client != null;
public override bool CanResignFirstResponder => true;
public override bool CanBecomeFirstResponder => true;
@ -23,8 +30,8 @@ public partial class AvaloniaView : ITextInputMethodImpl
{
get
{
if (_currentClient is { } && _currentClient.SupportsSurroundingText &&
_currentClient.SurroundingText.Text.Length > 0)
if (Client is { } && Client.SupportsSurroundingText &&
Client.SurroundingText.Text.Length > 0)
{
return true;
}
@ -47,6 +54,8 @@ public partial class AvaloniaView : ITextInputMethodImpl
}
}
public IUITextInputDelegate InputDelegate => _inputDelegate;
[Export("deleteBackward")]
public void DeleteBackward()
{
@ -63,9 +72,9 @@ public partial class AvaloniaView : ITextInputMethodImpl
void ITextInputMethodImpl.SetClient(ITextInputMethodClient? client)
{
_currentClient = client;
_client = client;
if (client is { })
if (_client is { })
{
BecomeFirstResponder();
}

2
src/iOS/Avalonia.iOS/AvaloniaView.cs

@ -30,6 +30,8 @@ namespace Avalonia.iOS
_topLevelImpl = new TopLevelImpl(this);
_touches = new TouchHandler(this, _topLevelImpl);
_topLevel = new EmbeddableControlRoot(_topLevelImpl);
_inputDelegate = new TextInputHandler();
_topLevel.Prepare();
_topLevel.Renderer.Start();

Loading…
Cancel
Save