home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a070 / 3.ddi / FOXPRO / GOODIES / DBLCLICK.PRG < prev    next >
Encoding:
Text File  |  1989-10-08  |  1.9 KB  |  59 lines

  1. *:*********************************************************************
  2. *:
  3. *:        Program: DBLCLICK.PRG
  4. *:
  5. *:         System: How To Detect Double-Clicks
  6. *:         Author: Fox Software, Inc.
  7. *:      Copyright (c) 1989, Fox Software, Inc.
  8. *:  Last modified: 10/08/89     13:23
  9. *:
  10. *:            Notes:    This routine illustrates the use of the new
  11. *:                    options of INKEY and use of the new
  12. *:                    _DBLCLICK system variable.  The main points
  13. *:                    illustrated are (1) use of SECONDS() and
  14. *:                    _DBLCLICK to implement a timed loop, (2) use
  15. *:                    of the new MROW and MCOL functions to detect
  16. *:                    the current mouse pointer position, and (3)
  17. *:                    the necessity of capturing the mouse position
  18. *:                    when the first click is detected.
  19. *:
  20. *:      Documented 10/08/89 at 13:28               FoxDoc  version 2.0
  21. *:*********************************************************************
  22. SET TALK OFF
  23. SET ESCAPE ON
  24. CLEAR
  25. X = 0
  26. DO WHILE .T.                && Exit by pressing Esc
  27.    X = INKEY("MH")            && INKEY detecting mouse-downs, no cursor
  28.    IF X=0                    && Nothing there,  try again.
  29.       LOOP
  30.    ENDIF
  31.    IF X = 27                && Exit if it's Esc.
  32.       EXIT
  33.    ENDIF
  34.    IF X = 151                && It's a mouse-down
  35.       ROW = MROW()            && Record row/column immediately
  36.       COL = MCOL()
  37.       timelimit = SECONDS()+_DBLCLICK    && Note: New system variable
  38.       y = 0
  39.       DO WHILE SECONDS() < timelimit
  40.          y = INKEY("MH")
  41.          IF y = 151            && Another click was just seen.
  42.             @ 10,10 SAY "Double click at"
  43.             EXIT
  44.          ENDIF
  45.       ENDDO
  46.       IF y = 0                && Here, if no further clicks seen.
  47.          @ 10,10 SAY "Single click at"
  48.       ENDIF
  49.       ?? ROW, COL
  50.    ENDIF
  51.    IF X # 151                && Here, if it wasn't a mouse-down
  52.       @ 10,10 SAY "Character typed: "
  53.       ?? "'"+CHR(X)+"'", TRANSFORM(X, "(999)"), SPACE(10)
  54.    ENDIF
  55. ENDDO
  56. SET TALK ON
  57. SET ESCAPE ON
  58. *: EOF: DBLCLICK.PRG
  59.