×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    21

    creating menu and sub menu

    In my application, i wanted to create a sub menu of items in the menu.

    When some of the menu items were copied to the new sub menu, the menu works, but when the menu items are cut and placed in the new menu the menu does't work, and program exits. Can somebody point me what i'm doing wrong.

    This is the first menu I created which worked ok.

    //----------------------------------------------------
    //
    // r_btphone_menubar
    //
    //----------------------------------------------------
    //
    RESOURCE MENU_BAR r_btphone_menubar
    {
    titles=
    {
    MENU_TITLE { menu_pane= r_btphone_menu; txt="Cmds"; }
    };
    }

    //----------------------------------------------------
    //
    // r_btphone_menu
    //
    //----------------------------------------------------

    RESOURCE MENU_PANE r_btphone_menu
    {
    items=
    {
    MENU_ITEM { command=EBTCmdSendDial; txt="Dial No."; },
    MENU_ITEM { command=EBTCmdSendMessage; txt="Contacts"; },
    MENU_ITEM { command=EBTCmdAnswerCall; txt="Answer call"; },
    MENU_ITEM { flags = EEikMenuItemSeparatorAfter;
    command=EBTCmdRejectCall;
    txt="Reject call";
    },
    MENU_ITEM { command = EBTCmdDeviceOptions;
    cascade = r_btphone_device_submenu;
    txt = "Devices";
    } ,


    MENU_ITEM { command=EBTCmdStartSlave; txt="Start Listening"; },
    MENU_ITEM { command=EBTCmdSelectLastDevice; txt="select Last device"; },
    MENU_ITEM { command=EBTCmdDiscoverDevices; txt="Discover devices"; },
    MENU_ITEM { command=EBTCmdConnectDevices; txt="Connect Devices"; },
    MENU_ITEM { command=EBTCmdShowConnectedDevices; txt="Show Connected"; },
    MENU_ITEM { command=EBTCmdMakeScoLink; txt="Make SCO link"; },
    MENU_ITEM { command=EBTCmdDeviceSaveOption; txt="Save Current Device"; },
    MENU_ITEM { command=EBTCmdHFReadOption; txt="Select saved HF"; },
    MENU_ITEM { command=EBTCmdDeviceSaveHF; txt="select HF device"; },
    MENU_ITEM { command=EBTCmdDisconnectDevices;txt="Disconnect device"; },
    MENU_ITEM { command=EBTCmdSetPasswd;txt="Set Password"; },
    MENU_ITEM { command=EAknCmdExit; txt="Exit"; }
    };
    }
    //------------------------------------------------------------------------

    RESOURCE MENU_PANE r_btphone_device_submenu
    {
    items=
    {
    MENU_ITEM { command=EBTCmdDeviceSaveOption; txt="Save Current Device"; },
    MENU_ITEM { command=EBTCmdShowConnectedDevices; txt="Show connected"; },
    MENU_ITEM { command=EBTCmdHFReadOption; txt="Select saved HF"; },
    MENU_ITEM { command=EBTCmdDeviceSaveHF; txt="select HF device"; },
    MENU_ITEM { command=EBTCmdSetPasswd;txt="Set Password"; }
    };
    }



    But when I modified the menus to remove the repeating menu items, it don't work. this is the rss file parts which don't work.



    //----------------------------------------------------
    //
    // r_btphone_menubar
    //
    //----------------------------------------------------
    //
    RESOURCE MENU_BAR r_btphone_menubar
    {
    titles=
    {
    MENU_TITLE { menu_pane= r_btphone_menu; txt="Cmds"; }
    };
    }

    //----------------------------------------------------
    //
    // r_btphone_menu
    //
    //----------------------------------------------------

    RESOURCE MENU_PANE r_btphone_menu
    {
    items=
    {
    MENU_ITEM { command=EBTCmdSendDial; txt="Dial No."; },
    MENU_ITEM { command=EBTCmdSendMessage; txt="Contacts"; },
    MENU_ITEM { command=EBTCmdAnswerCall; txt="Answer call"; },
    MENU_ITEM { flags = EEikMenuItemSeparatorAfter;
    command=EBTCmdRejectCall;
    txt="Reject call";
    },
    MENU_ITEM { command = EBTCmdDeviceOptions;
    cascade = r_btphone_device_submenu;
    txt = "Devices";
    } ,


    MENU_ITEM { command=EBTCmdStartSlave; txt="Start Listening"; },
    MENU_ITEM { command=EBTCmdSelectLastDevice; txt="select Last device"; },
    MENU_ITEM { command=EBTCmdDiscoverDevices; txt="Discover devices"; },
    MENU_ITEM { command=EBTCmdConnectDevices; txt="Connect Devices"; },
    MENU_ITEM { command=EBTCmdMakeScoLink; txt="Make SCO link"; },
    MENU_ITEM { command=EBTCmdDisconnectDevices;txt="Disconnect device"; },
    MENU_ITEM { command=EAknCmdExit; txt="Exit"; }
    };
    }
    //------------------------------------------------------------------------

    RESOURCE MENU_PANE r_btphone_device_submenu
    {
    items=
    {
    MENU_ITEM { command=EBTCmdDeviceSaveOption; txt="Save Current Device"; },
    MENU_ITEM { command=EBTCmdShowConnectedDevices; txt="Show connected"; },
    MENU_ITEM { command=EBTCmdHFReadOption; txt="Select saved HF"; },
    MENU_ITEM { command=EBTCmdDeviceSaveHF; txt="select HF device"; },
    MENU_ITEM { command=EBTCmdSetPasswd;txt="Set Password"; }
    };
    }



    can somebody point to me what I'm doing wrong.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: creating menu and sub menu

    Are you using DynInitMenuPaneL?

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    21

    Re: creating menu and sub menu

    yes I'm using DynInitMenuPaneL in order to change the menu items shown for different situations. This is the coding of the DynInitMenuPaneL function i have used in this situation.


    void CBtPhoneAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
    {
    if (aResourceId == R_BTPHONE_MENU)
    {
    if (iBtEngine->iIsSlave)
    {
    // slave mode
    aMenuPane->SetItemDimmed(EBTCmdSendDial, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdDiscoverDevices, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdConnectDevices, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdStartSlave, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdHFReadOption, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdDeviceSaveOption, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdDisconnectDevices, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdRejectCall, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdAnswerCall, ETrue);

    if ( iBtEngine->iListener->IsConnected() )
    {
    aMenuPane->SetItemDimmed(EBTCmdSendMessage, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdSendDial, EFalse);
    }
    else
    {
    aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdSendDial, ETrue);
    }
    if(iBtEngine->isReceivingCall)
    {
    aMenuPane->SetItemDimmed(EBTCmdRejectCall, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdSendDial, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdAnswerCall, EFalse);
    }
    }
    else
    {
    // master mode
    aMenuPane->SetItemDimmed(EBTCmdDiscoverDevices, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdConnectDevices, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdSendDial, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdHFReadOption, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdDeviceSaveOption, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdDisconnectDevices, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdRejectCall, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdAnswerCall, ETrue);

    if ( iBtEngine->iDeviceDiscoverer->HasDevices() )
    {
    // we have found devices, show discover services item
    //aMenuPane->SetItemDimmed(EBTCmdDiscoverServices, EFalse);
    // disable slave option, entered master mode
    aMenuPane->SetItemDimmed(EBTCmdStartSlave, ETrue);

    }
    else
    {
    // disconnected
    }

    if ( iBtEngine->iServiceDiscoverer->HasServices() )
    {
    // we have found services, show connect item
    aMenuPane->SetItemDimmed(EBTCmdConnectDevices, EFalse);

    }
    else
    {
    // no services
    aMenuPane->SetItemDimmed(EBTCmdConnectDevices, ETrue);
    }

    if ( iBtEngine->HasConnections() )
    {
    // we are connected, show send message item
    aMenuPane->SetItemDimmed(EBTCmdSendMessage, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdSendDial, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdHFReadOption, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdDeviceSaveOption, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdDisconnectDevices, EFalse);
    }
    else
    {
    // disconnected
    //aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdShowConnectedDevices, ETrue);
    }
    if(iBtEngine->isReceivingCall)
    {
    aMenuPane->SetItemDimmed(EBTCmdRejectCall, EFalse);
    aMenuPane->SetItemDimmed(EBTCmdSendMessage, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdSendDial, ETrue);
    aMenuPane->SetItemDimmed(EBTCmdAnswerCall, EFalse);
    }
    }

    }
    }

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: creating menu and sub menu

    For example I have just picked your very first command in the cascade menu (EBTCmdDeviceSaveOption), and it seems to be dimmed in the
    Code:
    if (aResourceId == R_BTPHONE_MENU)
    while it is not part of your modified r_btphone_menu. Although the documentation of CEikMenuPane::SetItemDimmed does not mention panics, in practice this method crashes your code when you are trying to dim a non-existing item.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×