Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Enabling navigation using the keypad

Applications may need to allow navigation of the screen using the up, down, left, and right keys, even if touch support is enabled. Supporting navigation using keys allows the application to run on devices that are not touch enabled, and provides additional navigation options for touch-enabled devices.

To enable navigation using the keypad, an application's HandleEvent function needs to handle AVK_UP, AVK_DOWN, AVK_LEFT, and AVK_RIGHT to allow navigation of the screen using the keypad. The application can call IWidget_MoveFocus() with WIDGET_FOCUS_PREV or WIDGET_FOCUS_NEXT to move the focus to the previous or next widget. Next and previous widget are determined by the z-order of the widgets.

For example, the following code could be added to the HandleEvent function. In this case, AVK_LEFT and AVK_RIGHT do not change the focus.

         case EVT_KEY:
           switch (wParam) {
              // Up arrow key was pressed:
              case AVK_UP:
                  (void)IWidget_MoveFocus(pMe->piwRoot, (IWidget *)WIDGET_FOCUS_PREV);
		          (void)IWidget_MoveFocus(pMe->piwXYCon, (IWidget *)WIDGET_FOCUS_PREV);
		          break;
              // Down arrow key was pressed:
	          case AVK_DOWN:
                  (void)IWidget_MoveFocus(pMe->piwRoot, (IWidget *)WIDGET_FOCUS_NEXT);
		          (void)IWidget_MoveFocus(pMe->piwXYCon, (IWidget *)WIDGET_FOCUS_NEXT);
		          break;
              // Left arrow key was pressed:
	          case AVK_LEFT: 
		          break;
              // Right arrow key was pressed:
	          case AVK_RIGHT: 
		          break;
              default:
                  break;
                  
           }
           break;