title: Processing events in SurfaceView
body: <p>I am creating a custom Widget which extends SurfaceView and I am planning to use it for camera preview.</p>
  
  <p>In the main activity I tried to implement some event listeners but can't catch any event.</p>
  
  <p>This is the part of code where I tried to add an event listener:</p>
  
  <pre><code>videoPreview = (CaptureView)findViewById(R.id.capturePreview);
  
      videoPreview.setOnKeyListener(new OnKeyListener(){
          public boolean onKey(View v, int keyCode, KeyEvent event){
              switch(keyCode)
              {
              case KeyEvent.KEYCODE_CAMERA:
                  videoPreview.TakePicture();
                  return true;
              }
              return false;
          }
      });
  </code></pre>
  
  <p>If I press a button the LogCat outputs "Continuing to wait for key to be dispatched" line.</p>
  
  <p>Does anyone know how to implement event listeners in main activity using SurfaceView classes?</p>
  
  <p>Thanks!</p>