Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -677,5 +677,22 @@ public async Task When_ReadOnly_Toggled_Repeatedly()

Assert.AreEqual(updatedText.Length, textBox.SelectionLength);
}

#if __ANDROID__
[TestMethod]
public async Task When_TextBox_ImeAction_Enter()
{
var textBox = new TextBox
{
Text = "Text",
};

WindowHelper.WindowContent = textBox;
await WindowHelper.WaitForLoaded(textBox);

var act = () => textBox.OnEditorAction(textBox.TextBoxView, Android.Views.InputMethods.ImeAction.Next, null);
act.Should().NotThrow();
}
#endif
}
}
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,15 @@ public bool OnEditorAction(TextView v, [GeneratedEnum] ImeAction actionId, KeyEv
{
//We need to force a keypress event on editor action.
//the key press event is not triggered if we press the enter key depending on the ime.options
<<<<<<< HEAD

// TODO: include modifier info in KeyEvent constructor
OnKeyPress(v, new KeyEventArgs(true, Keycode.Enter, new KeyEvent(KeyEventActions.Up, Keycode.Enter)));
=======
var modifiers = e is not null ? VirtualKeyHelper.FromModifiers(e.Modifiers) : VirtualKeyModifiers.None;
RaiseEvent(KeyUpEvent, new KeyRoutedEventArgs(this, global::Windows.System.VirtualKey.Enter, modifiers));
RaiseEvent(KeyUpEvent, new KeyRoutedEventArgs(this, global::Windows.System.VirtualKey.Enter, modifiers));
>>>>>>> d023bb1f58 (fix(TextBox): Avoid NRE on Android on virtual keyboard enter)

// Action will be ImeNull if AcceptsReturn is true, in which case we return false to allow the new line to register.
// Otherwise we return true to allow the focus to change correctly.
Expand Down