[futurebasic] Re: PG And PointInRect

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1997 : Group Archive : Group : All Groups

From: AlStaff@...
Date: Sat, 22 Nov 1997 11:02:38 -0500 (EST)
<< Hi all, major question is, how would I implement a "clickable rectangle"
type of thing in a window withouthaving to create a button or object in that
area? >>

This is a test I wrote a while ago when I was trying to do the same thing.
The rectangle acts just like a button but is transparent.

DIM rect.8
CALL SETRECT (rect, 75,100,175,200)
gClicked = 0
END GLOBALS


'   ----- FUNCTIONS -----
LOCAL FN doMouse
 DIM mpt.2
 M = MOUSE(0)
 mpt.0 = MOUSE(2) : mpt.2 = MOUSE(1)
 gClicked = 0
 '    check if mouse is inside rectangle when button clicked
 LONG IF FN PTINRECT (mpt, rect)
  CALL INVERTRECT (VARPTR(rect))                  ' inverts rect (white to
black)
  gClicked = 1                                    ' clicked in rectangle
  WHILE MOUSE(0) <> 0                             ' while button down, keep
checking
   CALL GETMOUSE (mpt)
   LONG IF FN PTINRECT (mpt, rect)
    IF gClicked = 0 THEN CALL INVERTRECT (VARPTR(rect))
    gClicked = 1                                  ' in rect
   XELSE
    IF gClicked = 1 THEN CALL INVERTRECT (VARPTR(rect))
    gClicked = 0                                  ' not in rect
   END IF
  WEND
  IF gClicked = 1 THEN CALL INVERTRECT (VARPTR(rect))
 END IF
 CALL MOVETO (10,220)                             ' these 2 lines show it
works (remove)
 PRINT "Clicked = " gClicked
END FN


'   ----- MAIN -----
WINDOW 1, "Mouse Check", (3,41)-(509,338),1
CALL TEXTMODE(0)
PRINT "Click mouse button in rectangle."
PRINT "Press Command + Period to end."
CALL MOVETO (10,120)
PRINT "This text is here to show that the area is transparent."
CALL FRAMERECT (VARPTR(rect))                     ' remove for invisible
frame
ON MOUSE FN doMouse

WHILE 1                                           ' << could be WHILE
gClicked = 0
 HANDLEEVENTS
WEND


Al Staffieri Jr.

AlStaff@...
http://members.aol.com/AlStaff/index.html