Browse Source

use ime api to hide and show osk.

pull/7781/head
Dan Walmsley 5 years ago
parent
commit
d717d10de8
  1. 54
      src/iOS/Avalonia.iOS/AvaloniaUIResponder.cs
  2. 7
      src/iOS/Avalonia.iOS/AvaloniaView.cs

54
src/iOS/Avalonia.iOS/AvaloniaUIResponder.cs

@ -1,6 +1,56 @@
using Foundation;
using ObjCRuntime;
using UIKit;
using Avalonia.Input.TextInput;
namespace Avalonia.iOS; namespace Avalonia.iOS;
public class AvaloniaUIResponder [Adopts("UIKeyInput")]
public partial class AvaloniaView : ITextInputMethodImpl
{ {
public override bool CanResignFirstResponder => true;
public override bool CanBecomeFirstResponder => true;
public override bool CanBecomeFocused => true;
[Export("hasText")] public bool HasText => false;
[Export("insertText:")]
public void InsertText(string text)
{
}
[Export("deleteBackward")]
public void DeleteBackward()
{
}
void ITextInputMethodImpl.SetActive(bool active)
{
if (active)
{
var isFr = IsFirstResponder;
var next = NextResponder;
var result = BecomeFirstResponder();
}
else
{
ResignFirstResponder();
}
}
void ITextInputMethodImpl.SetCursorRect(Rect rect)
{
}
void ITextInputMethodImpl.SetOptions(TextInputOptionsQueryEventArgs options)
{
}
void ITextInputMethodImpl.Reset()
{
}
} }

7
src/iOS/Avalonia.iOS/AvaloniaView.cs

@ -2,12 +2,13 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Embedding; using Avalonia.Controls.Embedding;
using Avalonia.Controls.Platform;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Input.TextInput;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Rendering; using Avalonia.Rendering;
using CoreAnimation; using CoreAnimation;
using CoreGraphics;
using Foundation; using Foundation;
using ObjCRuntime; using ObjCRuntime;
using OpenGLES; using OpenGLES;
@ -42,7 +43,7 @@ namespace Avalonia.iOS
MultipleTouchEnabled = true; MultipleTouchEnabled = true;
} }
internal class TopLevelImpl : ITopLevelImpl internal class TopLevelImpl : ITopLevelImplWithTextInputMethod
{ {
private readonly AvaloniaView _view; private readonly AvaloniaView _view;
public AvaloniaView View => _view; public AvaloniaView View => _view;
@ -109,6 +110,8 @@ namespace Avalonia.iOS
public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } =
new AcrylicPlatformCompensationLevels(); new AcrylicPlatformCompensationLevels();
public ITextInputMethodImpl? TextInputMethod => _view;
} }
[Export("layerClass")] [Export("layerClass")]

Loading…
Cancel
Save