Sunday, March 27, 2011

Re: [android-developers] Re: How to capture key events from View subclass

Harsh, this doesn't make any sense.  You are suggesting that implementing onKeyDown will cause onTouchEvent to receive touches from the keyboard? That is not right. Also, the touches are not in my view, they are in the global keyboard.

From what I have found in other posts, onKeyDown/Up does not fire when pressing individual keys on the soft keyboard, only for the hard.  Why this is so is unclear to me, but that is what I am experiencing.

The only solution I have found so far is not a favorable one, subclass EditText and call addTextChangedListener with my own TextWatcher.

On Thu, Mar 24, 2011 at 11:49 PM, harsh chandel <harshdchandel@gmail.com> wrote:
ok you have to write the code for on key down 
and each time the key is pressed on soft keyboard you capture the event
and do whatever you  want to do with on press event
@Override
   public boolean onTouchEvent(MotionEvent event) {
       if (event.getAction() == MotionEvent.ACTION_DOWN) {
           _active = false;
       }

 this was what i was talking about


On Thu, Mar 24, 2011 at 5:56 PM, Rich E <reakinator@gmail.com> wrote:

On Tue, Mar 22, 2011 at 6:14 PM, harsh chandel <harshdchandel@gmail.com> wrote:
try ontouch method
get x and y coordinate   of the area clicked
and do as you want on the clicked event


harsh chandel, I am not sure that I understand you.. I am using onTouchEvent() to trigger the keyboard (imm.showSoftInput() code in my last post)... but I cannot get the pressed keys of the keyboard.  As it is not my keyboard (it is the system shared keyboard), I cannot re-implement any onTouchEvent method that it may hold, unless I am missing something in your suggestion.

There must be some event that I need to listen to (onKeyUp for the soft keyboard keys..), but I don't yet know how.

Thanks for the help,
Rich


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment