xamarin/Xamarin.Forms

Entry keyboard changed to default when setting entry text from behavior.

Aperta

#5561 aperta il 14 mar 2019

 (1 commento) (0 reazioni) (0 assegnatari)C# (1926 fork)batch import
e/3 :clock3:hackathonhelp wantedinactivep/Androidt/bug :bug:up-for-grabs

Metriche repository

Star
 (5644 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Description

I have a behavior on an Entry control. The behavior was to add a mask to the text while you enter it (from https://xamarinhelp.com/masked-entry-in-xamarin-forms/).

I noticed that whenever the behavior applied the mask, the keyboard was set back to the default one. IE if I set focus to the entry, then change the keyboard to the number keyboard and type numerical characters, the keyboard would switch back to the alphabet keyboard as soon as the mask was added.

I narrowed it down to these two lines that appear to be causing this: var entry = sender as Entry; entry.Text = "foo";

(in OnEntryTextChanged in the behavior).

Steps to Reproduce

  1. Click the entry box.
  2. Switch the keyboard to numerical keyboard.
  3. Type "1" (or anything) so that the OnEntryTextChanged will fire in the behavior.

Expected Behavior

"foo" displays in the entry and the keyboard is still the numeric keyboard.

Actual Behavior

"foo" displays in the entry, BUT the keyboard is now back to the default one.

Basic Information

This seems to be only on Android.

  • Version with issue: Latest Xamarin
  • IDE: Visual Studio 2017 Pro
  • Platform Target Frameworks:
    • Android: 8.1
  • Netstandard 2.0

Screenshots

Default keyboard when you tap into the entry (step 1): image

Numeric keyboard (Step 2): image

Keyboard defaulted after step 3: image

This is the test app I've used: App4.zip

Guida contributor