Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Keyboard suggestions don't trigger a TextChanged and don't update text on Return/Completion

$
0
0

If you have an Entry with KeyboardFlags.Suggestions active, it won't actually accept a suggestion if a user hits Return. It will appear to have accepted it visually, but TextChanged doesn't fire, and examining the Text property reveals the text that was typed, not the suggestion.

Pressing spacebar, touching the suggestion, or pressing any other punctuation that forcibly ends a word will trigger the TextChanged. Seeing as pressing Return triggers a "Completed" event, I would assume it should be picking up the suggested text.

Example ContentPage exhibiting the behavior, unable to get forum code tag to work correctly:

using System;
using Xamarin.Forms;

namespace SuggestionsBug
{
public class SamplePage : ContentPage
{
Entry entry = null;
Label lbl = null;

    public SamplePage()
    {
        entry = new Entry();
        entry.Keyboard = Keyboard.Create(KeyboardFlags.Suggestions);
        entry.MinimumWidthRequest = 100;
        entry.TextChanged += Entry_TextChanged;

        Button btn = new Button();
        btn.Text = "Send";
        btn.Clicked += SendMessage_Clicked;

        lbl = new Label();
        lbl.Text = "Text will go here";

        StackLayout layout = new StackLayout();
        layout.Children.Add(entry);
        layout.Children.Add(btn);
        layout.Children.Add(lbl);

        Content = layout;
        Padding = new Thickness(5, 18);
    }

    void Entry_TextChanged (object sender, TextChangedEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Text seen: " + e.NewTextValue);
    }

    void SendMessage_Clicked (object sender, EventArgs e)
    {
        lbl.Text = entry.Text;
    }
}

}


Viewing all articles
Browse latest Browse all 77050

Trending Articles