On Tue, Nov 1, 2011 at 9:33 AM, Aki <arnab...@gmail.com> wrote:
> Thats sad. Actually I need to detect Key combos. I figured detecting the key
> press events was the best way to proceed. Can you suggest an alternative?
> Some way using which I will be able to detect key combinations?

I would not recommend using key combinations.

> I know key combinations are not an Android convention.

Correct. Beyond that, there's no native support for the concept.
KeyEvents can have a meta key (e.g., ALT) mixed in with a regular key,
but that's it.

> Still, I would like
> to try something out. Any help would be great :)

You're welcome to subclass EditText, implement onKeyDown() and try
stuff out, but I think you're going to have problems.

For example, let's say you wanted to do something when the user
pressed A and B at the same time. You're going to have two KeyEvents,
one for A and one for B. Let's say A arrives first in onKeyDown(). You
have no way to know if B will be forthcoming or not. If you chain to
the superclass for A, you will wind up with an A in the EditText. If
the user then presses B, not only will you need to do whatever key
combination logic you want, but you will also have to get rid of the
A.

Also, bear in mind that device manufacturers tend to tinker with
EditText more than other widgets. Context menus, for example, are
unreliable, as some device manufacturers appear to have implemented
their own long-click handler and are bypassing the context menu
system. It's entirely possible device manufacturers are playing games
with keypresses as well, in ways that might foul up whatever sort of
key combination support you manage to work out.

Also also, bear in mind that not all devices are multitouch, and the
emulator is not multitouch.

> PS : Big fan of your books. Keep up the good work!

Thanks!

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.6 Available!

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to