Bug 6132 - EditText KeyPress delegate does not fire when soft keyboard displayed.
Summary: EditText KeyPress delegate does not fire when soft keyboard displayed.
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-07-15 23:32 UTC by Robert Castles
Modified: 2012-07-16 15:08 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Robert Castles 2012-07-15 23:32:57 UTC
The delegate defined here does not fire when the soft keyboard is present for an edittext:

someEditText.KeyPress += delegate( object sender, View.KeyEventArgs e ) {

  Console.WriteLine("KeyPress: " + e.KeyCode.ToString());
  e.Handled = false;
}

If, however, the keyboard is dismissed, then while the cursor is focused in the edittext, the delegate does fire.  It appears to be directly related to the soft keyboard being displayed.

A "TextChanged" delegate for the same EditText does fire, though, regardless of the soft keyboard display.
Comment 1 Jonathan Pryor 2012-07-16 15:08:05 UTC
This isn't a bug, this is how Android does things.

The EditText.KeyPress event is really the View.KeyPress event:

> http://androidapi.xamarin.com/?link=E%3aAndroid.Views.View.KeyPress

The View.KeyPress event in turn is a binding of the View.setOnKeyListener() method:

> http://developer.android.com/reference/android/view/View.html#setOnKeyListener(android.view.View.OnKeyListener)

which states:

> Register a callback to be invoked when a hardware key is pressed in
> this view. Key presses in software input methods will generally not
> trigger the methods of this listener.

In other worse, the View.KeyPress event is for _hardware_ key presses, not software keyboard keypresses.