EV_registerMenu Function (ROM Call 0x159)

events.h

void EV_registerMenu (void *MenuPtr);

Attaches a menu to an application.

Applications can register toolbar menus with the system event handler. EV_registerMenu registers the toolbar menu pointed to by MenuPtr with the current application. MenuPtr is exactly the same pointer as expected in MenuBegin function. Note that registering the menu will not automatically display nor activate the menu. The application will draw the menu (using MenuBegin) on receipt of CM_ACTIVATE message. So if you, for example, attach a new menu to the "Home screen" application, you need to send CM_ACTIVATE message to it too. Also, before calling EV_registerMenu, a CM_DEACTIVATE message should to be sent to the application.

When a menu is attached to the application, each keypress event (a CM_KEYPRESS message) which represents keys F1, F2 etc. activates the menu (more precise, it is dispatched to the MenuKey function). After execution of MenuKey, the value returned from it (this is the ID of the selected item, see MenuAddText) is sent as an event to the application. So, the ID value for each menu item must be carefully planned: if you want to have the "Cut" option in the menu, its ID needs to be 0x720 (CM_MENU_CUT). Options which represent tokens (as in "Algebra" and "Calc" submenus) have ID less than 0x500, because tokens are send as XR strings (see XR_stringPtr). If you plan to create a serious event driven application which has toolbar menus (a flash application for example), it must behave in the same way (i.e. its event handler must process F-key events as described), and it must respond on CM_ACTIVATE message as described above. Of course, how to put an application in Flash ROM without TI certificate and TI professional SDK is greater problem...

To restore the original menu after termination of the program, you need to get a pointer to the original menu first, and before termination, you have to call EV_registerMenu again passing this pointer to it. The pointer can be obtained by calling OO_GetAppAttr like this:

void *oldmenu = OO_GetAppAttr (EV_runningApp, OO_APP_DEFAULT_MENU);


Note: Sending NULL to EV_registerMenu unattaches the toolbar menu from the application. Here is a dirty example which first removes the menu from the "Home screen" application, then changes parameters of "Home screen" parent window to expand the "Home screen" stack area into the menu area (but note that only a reset would restore the original state after execution of this program):
EVENT ev;
ev.Type = CM_DEACTIVATE;
EV_sendEvent (AP_CURRENT, &ev);
EV_registerMenu (NULL);
ev.Type = CM_ACTIVATE;
EV_sendEvent (AP_CURRENT, &ev);
FirstWindow->Client.xy.y0 = 0;
FirstWindow->Window.xy.y0 = 0;
FirstWindow->Clip.xy.y0 = 0;


Uses: EV_runningApp, OO_SetAppAttr
Used by: ROM Call 0x45B