image boundaries

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
revmeup
Posts: 3
Joined: Sat May 12, 2007 5:59 pm

image boundaries

Post by revmeup » Fri May 18, 2007 1:27 am

How would I set a boundary for an image on a stack, such that only the image can be moved within the boundary. Please help me. Thanks.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Fri May 18, 2007 2:10 am

You need to be more wordy in your question. I can only guess what you actually mean.

To move your image around on your stack with the mouse, put this in your images script:

Code: Select all

on mouseDown
  grab me
end mouseDown
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Re: image boundaries

Post by Mark Smith » Sat May 19, 2007 2:46 am

revmeup wrote:How would I set a boundary for an image on a stack, such that only the image can be moved within the boundary. Please help me. Thanks.
Let's say you have a rectangle graphic "tRect" that defines the boundaries,
something like this in the script of the image should work:

Code: Select all

local sRect

on mouseEnter
    put the height of me / 2 into tH
    put the width of me / 2 into tW
    put the rect of grc "tRect" into sRect
    add tW to item 1 of sRect
    subtract tW from item 3 of sRect
    add tH to item 2 of sRect
    subtract tH from item 4 of sRect
end mouseEnter
  

on mouseMove
  if the mouse is down then
    if the mouseLoc is within sRect then set the loc of me to the mouseLoc
  end if
end mouseMove
Best,

Mark

Post Reply