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 - picksetudf() associate a routine with a list http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 picksetudf()        Associate a routine with a list
------------------------------------------------------------------------------
 Declaration
   pick.hdr

 Syntax
   proc picksetudf extern
   param value _LIST pList, ;
         value ulong pFunction

 Arguments
   pList is a list pointer.
   pFunction is a keyboard handler function to install.

 Return
   None.

 Description
   The picksetudf() function associates a function with a list.

   The pickdisp() function uses the pickkeystd() function as
   the default keyboard handler to react on user input. A custom
   keyboard handler function can be installed via picksetudf(). In this
   case, the new keyboard handler must have a prototype identical to
   that of the pickkeystd() function.

   This function is normally used with string lists to be displayed via the
   pickdisp() function.

 Example
   #define EXAMPLE_LIST
   #include example.hdr

   // This example demonstrates repositioning the selection bar
   
   func uint PDFUNC ptr          // function pointer type declaration
   param value _SLIST pList, ;
         value uint   uStatus, ;
               uint   uItemCurr
   
   /*
   The following static variable is a function pointer. It is for
   indirectly calling the default keyboard handler (named pickkeystd())
   */
   
   vardef static
      ptr( PDFUNC ) pKeyStd := &pickkeystd // pointer to standard kbd handler
   enddef
   
   func uint SetRec static       // custom keyboard handler
   param value _SLIST pList, ;   // prototype must be identical
         value uint   uStatus, ; // to that of the pickkeystd() function
               uint   uItemCurr  // (also declared above as PDFUNC)
   
   if uStatus == PDS_INIT        // if pickdisp() is being set up
      uItemCurr := 2             // move selection bar to 2nd item
      return( PDC_GOTO )         // instruct pickdisp() to reposition the bar
   endif
   
   // process keypresses via default function (optionally direct or indirect)
   return( pKeyStd( pList, uStatus, uItemCurr ) )      // indirect call
   //return( pickkeystd( pList, uStatus, uItemCurr ) ) // direct call
   endfunc
   
   proc Test_picksetudf
   vardef
      _SLIST pList
   enddef
   clear
   pList := pickinit()
   pickadd( pList, "one" )
   pickadd( pList, "two" )
   picksetudf( pList, &SetRec )    // set up the custom keyboard handler
   pickdisp( pList, 10, 10, 11, 15 )
   pickclear( pList )
   endproc

   proc main
   Test_picksetudf()
   endproc

See Also: pickkeystd() pickudf()

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