[Solved] OnKeyListener -pass onKey to default handler?

Put your problem here if it does not fit any of the other categories.

[Solved] OnKeyListener -pass onKey to default handler?

Postby Anil » Fri Mar 07, 2008 5:57 pm

In OnKeyListener, how does one pass off the event to be processed by
the regular handler - since there is no super call?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle icicle) {
  2.  
  3.         super.onCreate(icicle);
  4.  
  5.         this.getListView().setFocusableInTouchMode(true);
  6.  
  7.         this.getListView().setFocusable(true);
  8.  
  9.  
  10.  
  11. this.getListView().setOnKeyListener(new OnKeyListener() {
  12.  
  13.         public boolean onKey(View v, int arg1, KeyEvent event) {
  14.  
  15. if(event.getAction() == KeyEvent.ACTION_DOWN)
  16.  
  17.                 Log.v("hey","pressed " + event.getKeyCode());
  18.  
  19. return true;
  20.  
  21.         }
  22.  
  23.  
  24.  
  25. });
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

-
Anil
Anil
Developer
Developer
 
Posts: 44
Joined: Fri Jan 04, 2008 9:15 pm

Top

Re: OnKeyListener - process event afterwards by regular hand

Postby Anil » Fri Mar 07, 2008 6:09 pm

Anil wrote:In OnKeyListener, how does one pass off the event to be processed by
the regular handler - since there is no super call?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle icicle) {
  2.         super.onCreate(icicle);
  3.         this.getListView().setFocusableInTouchMode(true);
  4.         this.getListView().setFocusable(true);
  5.  
  6. this.getListView().setOnKeyListener(new OnKeyListener() {
  7.         public boolean onKey(View v, int arg1, KeyEvent event) {
  8. if(event.getAction() == KeyEvent.ACTION_DOWN)
  9.                 Log.v("hey","pressed " + event.getKeyCode());
  10. return true;
  11.         }
  12.  
  13. });
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

-
Anil


Hi,

Have you looked at the meaning of the value 'true' you are returning?
It means that you handled the key and therefore that other views or
listeners should ignore the event. If all you want to do is watch the
key events you will need to return false. Also, as I explained in your
bug report, you could override dispatchKeyEvent.

--
Romain Guy
Anil
Developer
Developer
 
Posts: 44
Joined: Fri Jan 04, 2008 9:15 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests