One-step usage of the dynamic pop-up menu by pressing the validation key in the container is:
Tkeyresponse ccontextmenucontainer: offerkeyeventl (const tkeyevent & akeyevent, teventcode Atype)
{
// If the select key (OK key in emulator) is pressed, show the context sensitive Menu
Tbool selectkeypressed = (Atype = eeventkey) & (akeyevent. icode = ekeyok );
Tbool savedgamelistnotempty = (isavedgameslistbox) & (isavedgameslistbox-> model ()-> numberofitems ()> 0 );
If (selectkeypressed & savedgamelistnotempty)
{
// Get the menu bar from the parent of this control.
Ceikmenubar * parentmenubar = ieikonenv-> appuifacloud ()-> menubar ();
// Set the menu bar to the context-sensitive Menu Bar
Parentmenubar-> setmenutitleresourceid (r_contextmenu_saved_games_menu_bar );
// Try to display the context sensitive Menu Bar
If (parentmenubar)
{
Parentmenubar-> trydisplaymenubarl ();
}
// Change The Menu Bars resource to the normal menu bar so that the Left softkey displays
// The correct menu
Parentmenubar-> setmenutitleresourceid (r_contextmenu_menu_bar );
Return ekeywasconsumed;
}
// Otherwise, offer the key to The ListBox to process.
Else
Return isavedgameslistbox-> offerkeyeventl (akeyevent, Atype );
}
Ceikmenubar * parentmenubar = ieikonenv-> appuifacloud ()-> menubar ();
At the beginning, there was no problem in the container mode. In view + container mode, an error occurs. parentmenubar is a null pointer. The solution is as follows: Pass the view pointer to container and replace the preceding statement
Ceikmenubar * parentmenubar = iparentview-> menubar ();
.