home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / xbase / library / clipper / keyboard / hotget / hotget.prg < prev    next >
Text File  |  1992-04-24  |  3KB  |  89 lines

  1. /* -------------------------------------------------------------------------
  2.  
  3.   Copy Right,  April 1992              Donated to Public Domain
  4.   Auther: Jamal Assaf
  5.   --------------------------------------------------------------------------
  6.   Purpose  : Activate Hot Keys from  @ GET
  7.   Advantage: - Hot keys activated are 'local' to current get.
  8.              - No need to modify getsys.prg.
  9.              - You don't have to worry about activating and deactivating
  10.                the hot key.
  11.              - More important is makes your life easier!
  12.  
  13.   Compile with: /n/m
  14.                       ****** Have Fun *******
  15.  
  16.  
  17.   Example: (Hey, this is just an example)
  18.  
  19.      FUNCTION GetCust()
  20.           LOCAL getlist := {}, cCustCode := SPACE(10)
  21.  
  22.           @ 5,10 SAY "Enter Customer Code (F5-Lookup): " GET cCustCode ;
  23.                  HOTKEY K_F5, {|| LookupCust(@cCustCode, @cTitle)}
  24.           @ 6,2  SAY "Title : " GET cTitle
  25.           READ
  26.      RETURN NIL
  27.  
  28.      FUNCTION LookupCust(cCode, cTitle)
  29.  
  30.            SEEK cCode
  31.            IF FOUND()
  32.               cTitle := CUSTOMER->CUST_TITLE
  33.            ENDIF
  34.      RETURN NIL
  35.  
  36.  
  37.  
  38.      Please note  that the HOTKEY parameters are seperated by
  39.           a comma, and the procedure or function called is a code block.
  40.           Remember that the new #xcommand works in conjuction with
  41.           similar processor commands found in STD.CH like @ SAY...GET....
  42.           If there is a better way to do this, please share your ideas.
  43.  
  44. ----------------------------------------------------------------------- */
  45.  
  46.  // Example Begins:
  47.  
  48.  #include "inkey.ch"
  49.  #include "hotget.ch"
  50.  
  51.  FUNCTION TestHotGet()
  52.    LOCAL getlist := {}, cName := SPACE(15), cAddress := SPACE(20), ;
  53.          cHelp := "F1 Pressed...It is working"
  54.    CLS
  55.    SETCOLOR("W+/B")
  56.    @ 15,10 SAY "Press ESCAPE to exit" COLOR "GR+/R"
  57.    DO WHILE LASTKEY() != K_ESC
  58.       @ 10,10 SAY "Enter Name (F1-ShowHelp)   : " GET cName ;
  59.                    HOTKEY K_F1, { || ShowHelp(cHelp) }
  60.  
  61.       @ 12,10 SAY "Enter Address (F5-Test it) : " GET cAddress ;
  62.                    HOTKEY K_F5, { || ShowHelp("F5 was pressed") }
  63.       READ
  64.    ENDDO
  65.  
  66.  RETURN NIL
  67.  
  68.  FUNCTION ShowHelp(cHelp)
  69.  
  70.     @ 22,0 say PADR(cHelp + "   " + "Press any key to continue...",75) COLOR "G/N"
  71.     INKEY(0)
  72.     @ 22,0 SAY PADR(" ",75)  COLOR "G/N"      // clear line
  73.  
  74.  RETURN NIL
  75.  
  76.  // Example Ends
  77.  
  78.  
  79. //************************************************************************
  80.  
  81.  // This code is required for the HOTKEY to work properly.
  82.  
  83. FUNCTION HotKeySet(oGet, nKeyVal, bKeyBlock)
  84.    SetKey( nKeyVal, bKeyBlock )
  85.    GetReader(oGet)
  86.    SetKey( nKeyVal, NIL)
  87. RETURN NIL
  88.  
  89.