0 Replies Latest reply on Mar 5, 2012 1:08 PM by PagePageUI

    only keyboard navigation on an application

    PagePageUI

      Hello,

       

      I wrote a keyboard navigation for an application. The way i did it makes it difficult to expand and unusable. I stored the location on the components in an object of an object and then set the focus based on the location of the component that is being focused. I bet there is a better way to implement a keyboard navigation. Please help me out. Here's is the snipit of my code:

       

      mainapp.xmxl

      ....

      ....

      protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void

                  {

                      nav_content_container.first = {left:last, right:second, up:fourth, down:fourth};

                      nav_content_container.second = {left:first, right:third, up:fifth, down:fifth};

                      nav_content_container.third = {left:second, right:fourth, up:last, down:last};

                      nav_content_container.fourth = {left:third, right:fifth, up:first, down:first};

                      nav_content_container.fifth = {left:fourth, right:last, up:second, down:second};

                      nav_content_container.last = {left:fifth, right:first, up:third, down:third};

                     

                      nav_menu_container.searchTextInput = {left:nav_content_container.first.left, right:nav_content_container.last.right, up:byGenreBtn, down:newReleaseBtn};

                      nav_menu_container.newReleaseBtn = {left:nav_content_container.first.left, right:nav_content_container.last.right, up:searchTextInput, down:byGenreBtn};

                      nav_menu_container.byGenreBtn = {left:nav_content_container.first.left, right:nav_content_container.last.right, up:newReleaseBtn, down:searchTextInput};

       

                      this.addEventListener(KeyboardEvent.KEY_DOWN, handle_keypress,false);

      ...

      ...

      }

       

      protected function handle_keypress(event:KeyboardEvent):void

      {

           var key:Number = event.keyCode;

           .....

           .....

          

          

      case Keyboard.RIGHT: //right keycode: 39

      {

             if((pattern.indexOf("content_container")) > 0)

             {

                                    //elem_id is the up,down,left, right in the object of object nav_content_container or nav_menu_container

                                  IFocusM.setFocus(nav_content_container[elem_id].right); //this is how i set the focus based on the location in nav_content_container

                                  drawInitialFocus(nav_content_container[elem_id].right);

                                  IFocusM.getFocus().drawFocus(true);

                                  focused_component = String(IFocusM.getFocus());

                                  trace('Focus is now on ' + focused_component);

              }

              else    

                 .....

                 ....

      }

       

       

      //this is in the mxml section of the main application

       

      <s:Button id="first" width="168" height="112" icon="images/charlottes_web.jpeg"/>

      <s:Button id="second" icon="images/bad_lieutenant.jpeg" focusColor="#28ff2b"/>

      <s:Button id="third" icon="images/caroline.jpeg" focusColor="#28ff2b"/>

      <s:Button id="fourth" icon="images/che.jpeg" focusColor="#28ff2b"/>

       

      </s:WindowedApplication>