are image objects moveable?

Marty Billingsley marty at vertex.ucls.uchicago.edu
Wed Feb 25 12:12:44 EST 2004


> "kweto" <nrkweto03 at hotmail.com> asks
>
> Is there a (simple) way of enabling a user to use a mouse to pick up an
> image object and then move it around on a card? I.e., click and hold on an
> image with mouse left-button, move image by moving mouse, and then release
> mouse left-button.

A down-and-dirty way to do this is with the following handler in
the script for the image object:
on mouseStillDown
  set the loc of me to the mouseLoc
end mouseStillDown


> Also, if the reason for moving the image object is to place it into a
> container, then, what type of object would serve best as a container (image
> object? button object?), and how would I identify when the moved image
> object is on/over the container?

You could ask if the center of the image object is within the rect
of the container object (it doesn't matter what kind you use: button,
image, rectangle, or whatever).  In the mouseStillDown handler, add
the line:
  if the loc of me is within the rect of image "container"
  then .....

Again, this is a pretty simple way to do it; doesn't check to see if
the whole area of the image is within the container.

  - marty

--
Marty Billingsley (marty at ucls.uchicago.edu)
The University of Chicago Laboratory Schools

    "We are our choices...."
                   - Sartre


More information about the use-livecode mailing list