×
Namespaces

Variants
Actions

如何定义子菜单

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
翻译:
hoolee
最后由 hamishwillee 在 22 Dec 2011 编辑

在你的project.rss中定义如下:

RESOURCE EIK_APP_INFO
{
menubar = r_menubar;
cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
}
 
RESOURCE MENU_BAR r_menubar
{
titles =
{
MENU_TITLE { menu_pane = r_menu; }
};
}
 
RESOURCE MENU_PANE r_menu
{
items =
{
MENU_ITEM
{
command = ECommands;
txt = "Commands";
cascade = r_commands_submenu_pane;
},
MENU_ITEM
{
command = EAknSoftkeyExit;
txt = qtn_exit;
}
};
}
 
RESOURCE MENU_PANE r_commands_submenu_pane
{
items =
{
MENU_ITEM
{
command = ECommand1;
txt = "Command1";
},
MENU_ITEM
{
command = ECommand2;
txt = "Command2";
}
};
}

在你的project.hrh定义如下

enum TProjectIds
{
ECommands = 0x6001, // start value must not be 0
ECommand1,
ECommand2
};

最后在你的AppUi类中定义方法如下

void CProjectAppUi::HandleCommandL( TInt aCommand )
{
switch( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
 
case ECommand1:
// on command 1 action
break;
 
case ECommand2:
// on command 2 action
break;
default:
Panic( EUnknownCommand ); // from project.pan file
break;
}
}
This page was last modified on 22 December 2011, at 08:02.
43 page views in the last 30 days.
×