Wednesday, June 22, 2011

[android-developers] Re: "translated" onKeyDown

>
> Searching the docs for "keyboard character":http://developer.android.com/reference/android/view/KeyCharacterMap.h...,
> int)

The last day I readed this two times and it is not what I need. But I
have to thank you any way, as you sugested it to me I gave it a second
chance and following some link I finally found a solution by using
some MetaKeyKeyListener's functions.

The solution is not as simple as my hypothetical onCharAvailable, but
is working well, take a look:


public boolean onKeyDown(int keyCode, KeyEvent event){
long newState= MetaKeyKeyListener.handleKeyDown(metaState, keyCode,
event);

//TODO mas se nao for letra tem que chamar o super....

if(metaState == newState){ //foi uma tecla comum (nao shift nem alt
nem sym)
int c=
event.getUnicodeChar(MetaKeyKeyListener.getMetaState(newState));

if(c == 0) //liberar coisas como menu e voltar
return super.onKeyDown(keyCode, event);
else{
Log.v(TAG,"Got: "+c);
metaState= MetaKeyKeyListener.adjustMetaAfterKeypress(metaState);

this.setText(""+this.getText()+(char)c);

if(ncListener != null)
ncListener.onCharAvailable(c);
}
}else
metaState = newState;

return true;
}

--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate