home *** CD-ROM | disk | FTP | other *** search
- // GetMouse.prg
- //
- // Get reader implementing mouse
-
- #include "GetExit.ch"
- #include "Mouse.ch"
-
- MEMVAR GetList
-
- proc GetMouseReader( oGet )
-
- LOCAL nCurrentGet
- LOCAL nKey
- LOCAL lHadMouse, lHadKey, lLeftPressed, lRightPressed
- LOCAL nRow, nCol
- LOCAL nMouseGet
- LOCAL lWhen
- LOCAL lValid
-
- nCurrentGet := Ascan(GetList, {|o| o == oGet })
- IF !(GetMovingTo() == NIL) .AND. nCurrentGet != GetMovingTo()
- IF nCurrentGet > GetMovingTo()
- oGet:exitState := GE_UP
- ELSE
- oGet:exitState := GE_DOWN
- ENDIF
- ELSE
- GetMovingTo(NIL)
- // read the GET if the WHEN condition is satisfied
- MouseOff()
- lWhen := GetPreValidate(oGet)
- MouseOn()
- IF ( lWhen )
- // activate the GET for reading
- MouseOff()
- oGet:SetFocus()
- MouseOn()
-
- DO WHILE ( oGet:exitState == GE_NOEXIT )
- // check for initial typeout (no editable positions)
- IF ( oGet:typeOut )
- oGet:exitState := GE_ENTER
- ENDIF
-
- // apply keystrokes until exit
- DO WHILE ( oGet:exitState == GE_NOEXIT )
- lHadMouse := .F.
- lHadKey := .F.
- DO WHILE !lHadKey .AND. !lHadMouse
- nKey := InKey()
- lHadKey := nKey != 0
- IF !lHadKey
- // No key, check mouse
- MouseRead(@lLeftPressed, @lRightPressed, @nRow, @nCol)
- nRow := Int(nRow / M_CURS_HEIGHT)
- nCol := Int(nCol / M_CURS_WIDTH)
- IF lLeftPressed .OR. lRightPressed
- nMouseGet := Ascan(GetList, ;
- {|o| nRow == o:row .AND. ;
- nCol >= o:col .AND. ;
- nCol <= o:col + ;
- Len(Transform(o:Varget(), ;
- o:Picture)) - 1})
-
- lHadMouse := nMouseGet > 0
- ENDIF
- ENDIF
- ENDDO
-
- IF lHadKey
- MouseOff()
- GetApplyKey(oGet, nKey)
- MouseOn()
- ELSE
- GoToGet(nMouseGet)
- ENDIF
- ENDDO
-
- // disallow exit if the VALID condition is not satisfied
- MouseOff()
- lValid := GetPostValidate(oGet)
- MouseOn()
- IF ( !lValid )
- oGet:exitState := GE_NOEXIT
- ENDIF
- ENDDO
-
- // de-activate the GET
- MouseOff()
- oGet:KillFocus()
- MouseOn()
- ENDIF
- ENDIF
-
- RETURN
-