Creating a Simple Menu

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:

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';
Here is one of the maps used by the DFSETUP utility in MAPPOST format

Calling map_choose()

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.