Default Edit Menu
Problem
This example shows how to implement a default Edit menu into an application using GCC (it was taken of the Code Warrior examples included with the PalmOS? SDK).This way you save code for handling these functions: Copy, Paste, Cut, Undo, Select All, Keyboard and Graffiti .
Solution
Define the following resource IDs. PilRC will print a warning if you don't use the --allowEditIDs command line switch:
// System Menu Bar and Menus
#define sysEditMenuID 10000
#define sysEditMenuUndoCmd 10000
#define sysEditMenuCutCmd 10001
#define sysEditMenuCopyCmd 10002
#define sysEditMenuPasteCmd 10003
#define sysEditMenuSelectAllCmd 10004
#define sysEditMenuSeparator 10005
#define sysEditMenuKeyboardCmd 10006
#define sysEditMenuGraffitiCmd 10007
Then define the menu bar in your .RCP file like this (adapt to your needs):
// Menubars
MENU ID MainMenuBar
BEGIN
PULLDOWN "Edit"
BEGIN
MENUITEM "Undo" ID sysEditMenuUndoCmd "U"
MENUITEM "Cut" ID sysEditMenuCutCmd "X"
MENUITEM "Copy" ID sysEditMenuCopyCmd "C"
MENUITEM "Paste" ID sysEditMenuPasteCmd "P"
MENUITEM "Select all" ID sysEditMenuSelectAllCmd "S"
MENUITEM "-" sysEditMenuSeparator
MENUITEM "Keyboard" ID sysEditMenuKeyboardCmd "K"
MENUITEM "Grafitti" ID sysEditMenuGraffitiCmd "G"
END
PULLDOWN "Options"
BEGIN
MENUITEM "About..." ID OptionsAboutHipso
END
END
If you only have a form with an edit menu, you can specify the menu ID 10000 in the form and get the system's built-in Edit-only menu.
Here is the menu handle function:
Boolean PrvHandleMenu (UInt16 menuItem) {
Boolean result = false;
switch (menuItem) {
case OptionsAboutHipso:
FrmPopupForm (AboutBoxAlert);
result = true;
break;
default:
result = false;
break;
}
return result;
}
.
-- SabineDinisBlochberger - 14 Oct 2003
-- BenCombee - 30 Oct 2003 (added PilRC switch and menu ID 10000 note)