PrevNextUpHome SophiaFramework UNIVERSE 5.3

10.7. Menu

SophiaFramework provides the Responder classes below for menu processing.

Table 10.10. Menu Types

Class Name Description
SFRPlainMenu Responder which represents a plain menu without neither title nor frame.
SFRFrameMenu Responder which represents a frame menu.
SFRTitleMenu Responder which represents a menu with a title.
SFRTextMenu Responder which represents a text menu.

Figure 10.45. Example (softkey is pressed)

Example (softkey is pressed)

Example 10.48. How to Use Menu

// Declare a menu handler
HANDLER_DECLARE_VOIDMENU(MenuHandler)

// Menu handler
// 1st arg: class it belongs to
// 2nd arg: handler name
// 3rd arg: result
// 4th arg: menu (pointer to menu)
HANDLER_IMPLEMENT_VOIDMENU(TextMenu, MenuHandler, result, menu)
{
    // start when select key or clear key is pressed
    if (result == SRP16_ESCAPE) { // If clear key has been pressed
        TRACE("cancel");
    } else { // if select key has been pressed (result holds number of selected item)
        TRACE("%s", SFRTextMenuPtr(menu)->GetTitle(result));
    }
}

// declare menu
SFRTextMenuPtr menu;

// create menu
menu = ::new SFRTextMenu(SFXRectangle((50,100,150,150) "SFRTextMenu", null, 0);

// add items
menu->AppendItem("item1", AVK_1);
menu->AppendItem("item2", AVK_2);
menu->AppendItem("item3", AVK_3); 
menu->AppendItem("item4", AVK_4);

// register menu handler
menu->RegisterHandler(SREVT_MENU, HANDLER_BEFORE, HANDLER_FUNCTION(MenuHandler));

Figure 10.46. Execution Result

Execution Result