Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - menusethot() set the hot key mode of a menu http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 menusethot()        Set the hot key mode of a menu
------------------------------------------------------------------------------
 Declaration
   menu.hdr

 Syntax
   proc menusethot extern
   param value logical lSet

 Arguments
   lSet is the id of the new mode.

 Return
   None.

 Description
   This procedure activates ( lSet = .t. ), or de-activates ( lSet = .f. )
   the handling of hot-keys in the menus. If activated, ampersand characters
   in prompt texts are considered as hot-key markers, i.e. the characters
   right of the ampersands are taken as hot-keys for the prompts. For prompts
   that don't have a hot-key marker, the first non-white character in the
   prompt text is considered to be the hot-key.

   When prompts are displayed with the hot-key mode activated, the ampersand
   characters are not shown, and the hot-keys are displayed with the color
   attributes specified in the __syscolor[ CLR_UNSEL_CH ], or
   __syscolor[ CLR_SEL_CH ] array elements.

   The menu handlers that come with the menu system allow the selection of
   prompts by typing in hot-keys if this mode is active. When the hot-key
   mode is not active, the menu handlers default to the method used by
   former Force versions, i.e. seletions can be made by typing the initial
   of a prompt.

 Example
   #define EXAMPLE_MENU
   #include example.hdr

   func uint MyMenu
   param _MENU pMenu
   
   vardef
      uint  uKey
      int   iChoice
   enddef
   
   menudispall( pMenu )
   do while .t.
      uKey := toupper( getkey() )
      do case
      case uKey == K_UP
        menusetprev( pMenu )
      case uKey == K_DOWN
        menusetnext( pMenu )
      case uKey == K_ENTER
        iChoice := menucurrentid( pMenu )
        exit
      case uKey == K_ESC
        iChoice := 0
        exit
      case menuishot() .and. uKey >= 'A' .and. uKey <= 'Z'
        iChoice := menufindhot( pMenu, uKey )
        if iChoice > 0
           exit
        endif
      endcase
   enddo
   
   return iChoice
   endfunc
   
   proc Test_menusethot
   vardef
      _MENU pMenu
      uint  uSelect
   enddef
   
   cursor( .f. )
   clear
   
   pMenu := menunew()
   menusethot( .t. )
   menupromptnew( pMenu, 2, 10, " Opt&ion 1 ", 1, .t., .t. )
   menupromptnew( pMenu, 3, 10, " Op&tion 2 ", 2, .t., .t. )
   menupromptnew( pMenu, 4, 10, " Op&tion 3 ", 3, .t., .t. )
   menupromptnew( pMenu, 5, 10, " Optio&n 4 ", 4, .t., .t. )
   
   uSelect := MyMenu( pMenu )
   @ 10, 0 ?? "The selection is:", uSelect
   
   // Note that the '&' characters are now visible, and that the prompts
   // cannot be selected via hot-keys.
   //
   menusethot( .f. )
   uSelect := MyMenu( pMenu )
   @ 10, 0 ?? "The selection is:", uSelect
   
   menuclear( pMenu )
   
   cursor( .t. )
   
   endproc

   proc main
   Test_menusethot()
   endproc

See Also: menuishot()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson