Page 1 of 1

designating an area for export snapshot

Posted: Mon Jan 14, 2013 6:02 pm
by magice
I am adding an area image capture function to an one of my stacks. I would like a click and drag interface for designating the area to be captured. While the area is being dragged out, I want the mouse to draw a rectangle so the user can see the area being captured. I have been trying to do this with a rectangle graphic. but I cannot seem to get the rectangle to resize as it is being moved. Here is what I have so far

Code: Select all

on mouseDown
    global tFirstCord
    put the mouseLoc into tFirstCord
   set the topLeft of graphic dragArea to mouseLoc()
   set the visible of graphic dragArea to true
end mouseDown 


on mouseMove
     global tSecondCord
   put the mouseLoc into tSecondCord
     set the bottomRight of graphic dragArea to mouseLoc()
end mouseMove

on mouseUp
   global tFirstCord
   global tSecondCord
   set the visible of graphic dragArea to false
 end mouseUp
How can I lock the topLeft property so that when I change the bottomRight property the rectangle will resize instead of moving? Or am I completely on the wrong track?

Re: designating an area for export snapshot

Posted: Mon Jan 14, 2013 6:56 pm
by jmburnod
Hi Magice,
How can I lock the topLeft property so that when I change the bottomRight property the rectangle will resize instead of moving?
Yes, when you change de bottomright the control isn't resized.
Use the rect to "lock the topleft"

Code: Select all

local sTopleft
on mouseDown
       put the mouseLoc into sTopleft
    set the topLeft of graphic "dragArea" to sTopleft
      set the visible of graphic "dragArea" to true
end mouseDown 

on mouseMove x,y
   if sTopleft = empty then exit mousemove
   put sTopleft & "," & x & "," & y into trect
   set the rect of grc "dragArea" to trect
end mouseMove

on mouseUp
    set the visible of graphic "dragArea" to false
   put empty into sTopleft
end mouseUp

on mouserelease
   mouseUp
end mouserelease
Best regards
Jean-Marc

Re: designating an area for export snapshot

Posted: Mon Jan 14, 2013 7:10 pm
by magice
That did the trick. Thank you