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 - menufindhot() scan the prompts for a hot key http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 menufindhot()       Scan the prompts for a hot key
------------------------------------------------------------------------------
 Declaration
   menu.hdr

 Syntax
   func int menufindhot extern
   param value _MENU pMenu, ;
         value byte  bChar

 Arguments
   pMenu is the pointer to a previously created menu system. If 0, the
         default menu will be used.
   bChar is the character code to be searched for.

 Return
   An int indicating the result of the scan:

       0 - no match found
     > 0 - the id of the only match found
     < 0 - the negative id of the next match found if there are two or more
           matches.

 Description
   This function scans the prompts of all active items in the menu for a
   hot key that matches the character passed in the bChar argument. The scan
   is not case sensitive. If no specific hot key character is defined in a
   prompt, the first non-white character will be considered as hot key.

   The scan starts with the next active item following the current prompt,
   and continues until all items have been scanned up to the current item.

   If a matching item is found, it will automatically become current, and
   the prompts will be re-displayed. In this case, the scan continues to
   eventually find more items with a matching hot-key.

 Example
   #define EXAMPLE_MENU
   #include example.hdr

   proc Test_menufindhot
   vardef
      _MENU pMenu
      uint  uKey
      int   iId
   enddef
   
   clear
   cursor( .f. )
   menusethot( .t. )
   
   pMenu := menunew()
   
   menupromptnew( pMenu, 5, 5, " &Cut   ", 1, .t., .t. )
   menupromptnew( pMenu, 6, 5, " Co&py  ", 2, .t., .t. )
   menupromptnew( pMenu, 7, 5, " &Paste ", 3, .t., .t. )
   menupromptnew( pMenu, 8, 5, " &Quit  ", 4, .t., .t. )
   
   @ 10, 5 ?? "Press a hot-key..."
   @ 12, 5 ?? "menufindhot() returns:"
   
   repeat
      uKey := toupper( getkey() )
      if uKey >= 'A' .and. uKey <= 'Z'
         iId  := menufindhot( pMenu, uKey )
         @ 12, 28 ?? iId:2
      endif
   until iId == 4
   
   menuclear( pMenu )
   cursor( .t. )
   
   endproc

   proc main
   Test_menufindhot()
   endproc

See Also: menufindrc()

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