FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

MOUSE

Change the cursor over objects


If you are using PG Pro, then during gSubAction = _otherNullEvent place your routine to check if the mouse point (i.e., GETMOUSE(pt)) is in the rectangle in question (i.e., PTINRECT(pt,rect)). That will work.

If you are not in PG Pro, then figure out how to get a null event and place the same checking routine in it.

tedd



Below is a snippet of some of the code I use to do what you want to do. It's extracted from a working program with unimportant stuff removed (the IF's may not all balance but you should be able to get the idea.

The whole thing is set in motion with an ON EVENT FN DoEvent.

Charlie Dickman

LOCAL FN DoEvent
  DIM theEvent, thePoint.4, wnd&
  theEvent = {EVENT}
  thePoint;4 = EVENT+_evtMouse
  modKeys;2 = EVENT+_evtMeta
  optDown = modKeys AND _optionKey%
  cmdDown = modKeys AND _cmdKey%
  ctrlDown = modKeys AND _controlKey%
  activeWnd = WINDOW(_activeWnd)

  LONG IF WINDOW(-_myWindow)
    WINDOW OUTPUT #_myWindow
    CALL GLOBALTOLOCAL(thePoint)
    GET WINDOW #_myWindow, wnd&
    LONG IF FN PTINRGN(thePoint, wnd&.visRgn&)
      doCursor = _false
      inFaceRect = 0 : face = 1
      WHILE ((inFaceRect = 0) AND (face <= 8))
        LONG IF whatever
          inFaceRect = FN PTINRGN(thePoint, g3CubeRgnH&(face))
        XELSE
          inFaceRect = FN PTINRECT(thePoint, gFaces.faceRect(face))
        END IF
        INC(face)
      WEND
      LONG IF inFaceRect
        FN ResetCursor(_handCursor)
      XELSE
        FN ResetCursor(_arrowCursor)
    XELSE
      doCursor = _zTrue
    END IF
    face = 1 : tessie = 1 : inRgn = 0
    WHILE inRgn = 0 AND face <= _maxFace AND tessie <= _maxTessie
      LONG IF whatever
        inRgn = FN PTINRGN(thePoint, g3RgnH&(face,tessie))
      XELSE
        inRgn = FN PTINRGN(thePoint, gTRgnH&(face,tessie))
      END IF
      LONG IF inRgn = 0
        INC(tessie)
        LONG IF tessie > _maxTessie
          INC(face)
          tessie = 1
        END IF
      END IF
    WEND
    LONG IF inRgn <> 0
      COMPILE LONG IF _showMovedTessie
        FN DoTessieId(face, tessie, ctrlDown, optDown, cmdDown, doCursor)
      COMPILE XELSE
        FN DoTessieId(face, tessie, ctrlDown, 0, cmdDown, doCursor)
      COMPILE END IF
    XELSE
      IF doCursor THEN FN ResetCursor(_arrowCursor)
      IF LEN(EDIT$(_whichWhereEF)) <> 0 THEN EDIT$(_whichWhereEF) = ""
      CALL INVALRGN(gSelectedRgnH&)
      CALL SETEMPTYRGN(gSelectedRgnH&)
      DEF BLOCKFILL(@gtNdx(1),8,0)
    END IF
  XELSE
    FN ResetCursor(_arrowCursor)
      END IF
    END IF
  XELSE
    FN ResetCursor(_arrowCursor)
  END IF
END FN

Charlie


Thank you very much for your answer. I have used the FN PTINRECT which was also recommended by Tedd and it works fine.
In a nutshell: My application reads GPS position in a digital map and I want to be able to change cursor when the mouse is over a waypoint, so that I can drag it and place it somewhere else. Since the end point of the waypoint line is marked with a small square, I just call SETRECT to record the coordinate of the square and save the rectangle as a global.
In my DIALOG event function, I test if FN PTINRECT is _true, then change the cursor. As said, it works fine but I have to use negative cursor constants i.e. -_arrowCursor.
Don't know why but it works erratically otherwise.

Michel Verheughe