Handling the Middle Soft Key and Enter Key in AVKON lists

This document describes how to handle the Middle Soft Key (MSK) and Enter keys in AVKON lists.

If an application handles the list targeted MSK or Enter Key events (EKeyOK and EKeyEnter), for example, in the ProcessKeyEventL() function, the handling of these key events must be moved to the listbox observer function HandleListBoxEventL(). The MSK or Enter Key event related action must be performed when an EEventEnterKeyPressed event is received. This way the list item-specific action is performed on a key event only when there is an option highlighted in the list.

  • Remove key event handling code from ProcessKeyEventL.

    TBool CLogsDetailView::ProcessKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {
      if( aType == EEventKey )
      {
        switch( aKeyEvent.iCode )
        {
          ...
    //------ Remove this code-------------
    // 	case EKeyOK:
    // 	case EKeyEnter:
    //	Select key pressed
    // 	CmdContextMenuL();
    // 	return ETrue;
    
    //--------------------------------------        
           ...
            default:
            break;
        }
      }
    
  • Add key event handling code to HandleListBoxEventL.

    void CLogsBaseView::HandleListBoxEventL(
    CEikListBox* aListBox,
    TListBoxEvent aEventType)
    {
      ...
        switch ( aEventType )
      {
        ...
    //---------Add MSK and enter key handling code---------------- 
          case EEventEnterKeyPressed:
        {
          TInt commandId( Cba()->ButtonGroup()->CommandId(
            CEikButtonGroupContainer::EMiddleSoftkeyPosition ) );
          ProcessCommandL( commandId );
          break;
        }
    //-------------------------------------------------------------- 
     ...
          default:
    // HW key shortcuts
          break;
      }
    }
    
    
    ...
    }