0

I have a webView that I am displaying Google v3 API map inside. I have panControl and zoomControl that I need to navigate with the dPad. From my menu, I navigate right arrow and the dPad enters the webview on the left arrow of the panControl. Focus is seen by a blue hollow rectangle that will reposition on each arrow as I dPad through. A couple questions...

  1. How to I regain the focus (rectangle) once I press the center OK of dpad?
  2. How do I get a focus state on the zoomControl (the only state I have now is a pressed state that turns the + or - buttons blue when pressed...I need a focused state)?
  3. How to I know what element I am on (i.e - left arrow of panControl) so that I can take control of the dPad by returning true in my onKey?

Here is a screen shot so that you can see the rectangle I am speaking of for focus:

enter image description here

Below is code:

    mWebView.setOnKeyListener(new OnKeyListener() {

            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                // TODO Auto-generated method stub
                if (event.getAction() == KeyEvent.ACTION_UP) {
                    switch(keyCode) {
                        case KeyEvent.KEYCODE_DPAD_CENTER:
                            Log.i(DEBUG_TAG, "KEYCODE_DPAD_CENTER");

                            return false;
                        case KeyEvent.KEYCODE_DPAD_DOWN:
                            Log.i(DEBUG_TAG, "KEYCODE_DPAD_DOWN");
                            return false;
                        case KeyEvent.KEYCODE_DPAD_UP:
                            Log.i(DEBUG_TAG, "KEYCODE_DPAD_UP");
                            return false;
                        case KeyEvent.KEYCODE_DPAD_RIGHT:
                            Log.i(DEBUG_TAG, "KEYCODE_DPAD_RIGHT");
                            return false;
                        case KeyEvent.KEYCODE_DPAD_LEFT:
                            Log.i(DEBUG_TAG, "KEYCODE_DPAD_LEFT");
                            return true;
                    }
                    return false;
                }
                return false;
            }
        });

My ultimate goal is to be able to dpad inside the webview, and then when I reach the (-) of the zoom and press the down on dpad, I'd want to navigate to the "play" button and then right arrow across bottom of screen to other controls. If I left arrow from bottom controls and hit the "play" then I'd want to pop back out to the left navigation "Maps" item.

taraloca
  • 9,077
  • 9
  • 44
  • 77
  • 1
    I ended up making custom controls so I could have control of the focus. With that I added custom Javascript functions to handle the panning and zooming onClick of the custom controls. – taraloca Dec 02 '11 at 13:44

1 Answers1

1

Take a look at MapsOnTV sample code at https://code.google.com/p/googletv-android-samples/

Brose the source tree.