To create a menu that a user can move around using the mouse or cursor keys, set up a map with the required number of options:
If you are using a 4.6xx release of Mapedit you just need to create text controls with a field number: you use field number 1 for the text corresponding to option 1, field 2 for option 2 and so on. You can set a mnemonic for each option by putting an & before the appropriate character in the option text.
In 4.5xx releases you can't directly assign numbers to text items like this. Instead you simply type in the text, and then add a field 1 coinciding with option 1, field 2 with option 2, and so on. In this version of MAPEDIT you set up by mnemonics by using the mnemonic option in mapedit and moving the cursor to the appropriate point.
On 4.5xx it is also very easy to use a text editor to create menus, and to post them to the database with MAPPOST. Most maps for DP4 utilities are actually created this way! An example is shown below.
With either release it is important to set up the map properties as a popup menu with as many rows as there are options, and 1 column.
#sysdb
#mapname DFSETUP
#optleft '['
#optright ']'
#window 2 8 1 map_flags=2051
_________________________________________|
DP4 SYSTEM SETUP User Preferences
[1 Date and time input/display ]
[2 Number/character/menu input/display]
[3 Colours and miscellaneous cosmetics]
[8 Exit... (X) ]
________________________________________
#fields 1: select='D',
2: select='N',
3: select='C',
8: select='X';
|
Use the function map_choose to obtain the option from the user. For example:
if (map_choose(3, &option))
return FALSE;
else
switch (option)
{
... |
This displays the menu, and obtains the option, whether the user selects it by navigation, number, mnemonic or by function key.
If the user selects an option, map_choose returns 0 and sets variable pointed to by the second parameter to the field number of the chosen option. If the user presses <Esc>, it returns the value ESCAPE (defined in dp4uiapi.h). The return value is also stored in the global variable abort_code.
map_choose() clears the menu from the screen after an option has been selected.