How to Trap the Double Mouse Click on a Field

ID: Q95292

The information in this article applies to:

The following program traps the double mouse click on a GET field and displays the results in a WAIT WINDOW.

   CLEAR
   CLEAR ALL
   USE customer
   @2,2 GET contact
   @4,2 GET company WHEN one() VALID two()
   *** Enables ON KEY LABEL when the field is entered and
   *** disables it upon exit
   @6,2 GET city
   READ CYCLE
   ON KEY LABEL LEFTMOUSE

   PROCEDURE one
     ON KEY LABEL LEFTMOUSE DO three
     RETURN .T.

   PROCEDURE two
     ON KEY LABEL LEFTMOUSE
     RETURN

   PROCEDURE three
     ON KEY LABEL LEFTMOUSE
     SET TALK OFF
     y = INKEY ("MH")               && Checks for mouse click.
     x = INKEY (_DBLCLICK,"MH")     && Checks for double mouse click.

     IF x = 151
          row = MROW()       && Checks row where mouse was clicked.
          col = MCOL()       && Checks column where mouse was clicked.
          IF row = 4                   && Row of GET field.
              IF col > 1 AND col < 21      && Location of GET field.
                    WAIT WINDOW "Double"
                    _CUROBJ=OBJNUM(contact)
                    RETURN
                    EXIT
              ENDIF
          ENDIF
     ELSE
          row = MROW()       && Checks row where mouse was clicked.
          col = MCOL()       && Checks column where mouse was clicked.
          IF row = 4         && Row of GET field.
               IF col > 1 AND col < 21      && Location of GET field.
                    x=''
                    @ MROW(),MCOL() GET x WHEN x = 151
                    WAIT WINDOW "Single"
               ENDIF
          ENDIF
     ENDIF

     ON KEY LABEL LEFTMOUSE DO three
     RETURN

NOTE: A single mouse click no longer works while the cursor is on this field. To leave the field, press the TAB or ENTER key.

Additional reference words: FoxDos 2.00 double-click KBCategory: kbprg kbcode KBSubcategory:

Last Reviewed: April 17, 1995