2

I asked this previously on the Android dev mailing list but got no reply.

In my application, I bring the soft keyboard on from time to time, and it looks like events for the DEL key are not delivered. The method in question is at

http://pastebin.com/zZaZWJ4t

and the whole Java class is at

http://squeakvm-tablet.googlecode.com/hg/project/src/org/squeak/android/SqueakView.java

Any alphanumeric key or Enter (Return) tapped on the soft keyboard is passed to the application except for KEYCODE_DEL. I tried to replace KEYCODE_DEL in the case clause with anything else (e. g. with code for for hardware button PAGE_UP), and the clause takes control when that button is pressed.

I did not subclass the Android Keyboard class, just used the default input manager.

What can be done in order to receive events for KEYCODE_DEL? Is deriving a keyboard subclass the only way?

Thanks.

Dmitry
  • 201
  • 3
  • 4

2 Answers2

0

Your onCreateInputConnection() override is not returning TYPE_NULL as the input type. You must use TYPE_NULL to be assured that key events will be generated. They are in fact generated for some keys and not for others, in some versions of Android but not others, but there is nothing that you can count on about that unless you use TYPE_NULL.

If you do adjust your code to use TYPE_NULL, then please see this description of a workaround for two bugs in certain versions of the default LatinIME Google Keyboard that affect TYPE_NULL processing:

Android - cannot capture backspace/delete press in soft. keyboard

Community
  • 1
  • 1
Carl
  • 15,445
  • 5
  • 55
  • 53
0

I had a similar issue and I was able to solve it by adding a TextWatcher to EditText using addTextChangedListener.

pottedmeat
  • 3,391
  • 1
  • 18
  • 9
  • In fact, as I finally got the answer from the Android dev mailing list, the solution was not to derive any subclasses from BaseInputConnection, and reply with an instance of BaseInputConnection when asked. In such mode I am now getting every soft key to my view. But thanks anyway to everyone who paid attention to this question. – Dmitry Apr 18 '11 at 15:07
  • Hi Dmitry, I have save problem too. actually, onkeydown works fine many devices but "sony ericsson xperia x10 mini pro". did you try your application in "sonyericsson xperia x10 mini pro" ? – Adem Jul 19 '11 at 07:40
  • No, not on this one. The following Wiki page http://code.google.com/p/squeakvm-tablet/wiki/TinyBenchmark shows the list of devices other people tried my program (Smalltalk Cog VM port for Android, or CogDroid) on. I am not sure whether any of these had a hardware keyboard though: most of them are tablets. – Dmitry Sep 26 '11 at 18:29