In the previous section, we told the "button event" in the similar processing process in J2ME and Symbian, in fact, these things must be handled in a game, whether in any platform.
So in the mobile game, the menu is essential. In Symbian, there is no higher advanced UI and low-level UI, only the system controls and custom controls.
Then the interface interaction part can be a comparison with J2ME:
System Controls in J2ME in Advanced UI CommandAction () Symbian HandleCommandl ()
Custom Controls in J2ME in Low - level UI Keypressed () Symbian OfferKeyEventL ()
(3) System menu
And J2ME is not the same, the system control in Symbian is by editing in the resource file, independently specify the application's visible controls outside the source code. System controls that can be defined in resources include menus, dialogs, lists, and more.
The application framework opens the resource file when the application starts, and loads each resource into the C code as needed based on the resource identifier created in .rsg.
Such architectures have a certain advantage that the resource files and C source files can share the data defined in the resource file.
The identifier used in the command menu is typically defined in a file that is called .hrh.
The following example is taken from the Graphics example of SDK comes with:
#ifndef __graphics_hrh__ #define __graphics_hrh__
// graphics enumerate Command Codes Enum TgraphicsIDS {EgaphicsnooffScreenDemo = 1, EgaphicsOffscreenDemo, EgaphicsStopdemo};
#ENDIF / / __GRAPHICS_HRH__ The process of visible resource files is used to avoid the multifestator to avoid multiple inclusion. And. HRH file can only include EMNU and pre-processing statements, and other C syntax will result in resource editing failures, this requires special attention.
Below is the contents of the .RSS file corresponding to this. HRH file:
Name Grap
#include
#include "graphics.hrh"
/ / -------------------------------------------------------------------------------------------- --------- // // define the resource file signature // this resource sale be empty./// -------------------- ------------------------------------- // resource }_signature {}
/ / -------------------------------------------------------------------------------------------- --------- // // DEFAULT Document Name //// ------------------------------ --------------------------- // Resource TBUF {BUF = ""
/ / -------------------------------------------------------------------------------------------- --------- // // Define Default Menu and CBA Key.//// -------------------------- ------------------------------- // resource eik_app_info {menubar = r_graphics_menubar; CBA = r_avkon_softkeys_options_exit;} // --- -------------------------------------------------- ---- / // r_graphics_menubar // MenuBar for graphics example //// ------------------------------- -------------------------- // resource menu_bar r_graphics_menubar {titles = {menu_title {menu_pane = r_graphics_menu;}};
/ / -------------------------------------------------------------------------------------------- --------- / // r_graphics_menu // Menu for "options" //// ------------------------- -------------------------------- // resource menu_pane r_graphics_menu {items = {menu_Item {Command = EgaphicsnooffScreenDemo; txt = " No off screen bmp ";}, MENU_ITEM {command = EGaphicsOffScreenDemo; txt =" Off screen bmp ";}, MENU_ITEM {command = EGaphicsStopDemo; txt =" Stop Animation ";}, MENU_ITEM {command = EAknSoftkeyExit; txt =" Exit " ;}};} Some of the contents of this file is made:
Resource} {}
Resource TBUF {BUF = "";
These two general cases are not allowed to make changes, the former is the signature of the resource, the latter is the default document name.
============================================================================================================================================================================================================= =========================================== enu = r_graphics_menubar; CBA = r_avkon_softkeys_options_exit;}
The ID used to identify menus and shortcuts is a name to the menu and the corresponding shortcut to use it later.
============================================================================================================================================================================================================= ==========================================================================================================================================================
RESOURCE MENU_PANE r_graphics_menu {items = {MENU_ITEM {command = EGaphicsNoOffScreenDemo; txt = "No off screen bmp";}, MENU_ITEM {command = EGaphicsOffScreenDemo; txt = "Off screen bmp";}, MENU_ITEM {command = EGaphicsStopDemo; txt = "Stop Animation ";}, menu_item {command = EaknsoftKeyExit; txt =" exit ";}};} This is the real content of the actual definition menu, that is, we can see the Menu_Item identification and content of the Menu_Item.
============================================================================================================================================================================================================= ==============================================================================================================================================================================】 The method can be processed for the corresponding Command.
Void Cgraphicsappui :: Handlecommandl (Tint Acommand) {Switch (ACOSMAND) {Case EEIKCMDEXIT: CASE EAKNSOFTKEYEXIT: EXIT (); BREAK;
Case EgaphicsnooffscreenDemo: Iappview-> StartnooffscreenDemo (); Break;
Case EgaphicsoffScreenDemo: Iappview-> StartoffScreenDemo (); Break;
Case EgaphicsTopdemo: Iappview-> StopDemo (); BREAK
Default: User :: Panic (_L ("graphics"), egraphicsbasicui; Break;}}
Now you have learned the processing method in the Symbian corresponding to the advanced UI response in J2ME, and now interacts with users should have no problem. Whether it is the OFFERKEYVENTL () method of the button event, or the HandleCommandl () method for the menu command.