designating an area for export snapshot

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

designating an area for export snapshot

Post by magice » Mon Jan 14, 2013 6:02 pm

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?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: designating an area for export snapshot

Post by jmburnod » Mon Jan 14, 2013 6:56 pm

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
https://alternatic.ch

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: designating an area for export snapshot

Post by magice » Mon Jan 14, 2013 7:10 pm

That did the trick. Thank you

Post Reply