Hot and throbbing.

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10220
Joined: Fri Feb 19, 2010 10:17 am

Hot and throbbing.

Post by richmond62 » Mon May 25, 2015 11:10 am

One of the kids I teach asked how to make an image resize when the mouse was over it.

So I went, inevitably, for the easiest solution I could think of with this script
inside the image:

on mouseEnter
set the width of me to 150
set the height of me to 150
end mouseEnter
on mouseLeave
set the width of me to 120
set the height of me to 120
end mouseLeave

The kid was perfectly happy with that.

HOWEVER . . .

I noticed something interesting:

If the image is UNLOCKED it expands and contracts from it centre, while

if the image is LOCKED it expands and contracts from its top-left hand corner.

I don't know if this is documented anywhere (???) .

AND, I wonder if there is a way to force the image to expand and contract from another of its corners?
Attachments
PULSE.livecode.zip
Here's my example.
(19.06 KiB) Downloaded 172 times

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Hot and throbbing.

Post by Thierry » Mon May 25, 2015 11:15 am

richmond62 wrote: AND, I wonder if there is a way to force the image to expand and contract from another of its corners?
You can play with
the rect of image
Then you can change 1 to 4 of any corners..

Best,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10220
Joined: Fri Feb 19, 2010 10:17 am

Re: Hot and throbbing.

Post by richmond62 » Mon May 25, 2015 11:27 am

"set the rectangle of object to left,top,right,bottom"

Thanks, that's super.

SparkOut
Posts: 2961
Joined: Sun Sep 23, 2007 4:58 pm

Re: Hot and throbbing.

Post by SparkOut » Mon May 25, 2015 11:47 am

Although unlikely in this particular situation, watch out for esoteric changes to the rect that brings the edge to the other side of the mouse position, triggering another mouseEnter or mouseLeave which changes the rect again, which ... etc etc. Temporarily locking messages might be needed.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Hot and throbbing.

Post by MaxV » Mon May 25, 2015 2:06 pm

Using the rect needs to make some calculations. I prefer this: :wink:

########CODE#######
on mouseEnter
lock screen
put the loc of me into temp
set the width of me to 150
set the height of me to 150
set the loc of me to temp
unlock screen
end mouseEnter

on mouseLeave
lock screen
put the loc of me into temp
set the width of me to 120
set the height of me to 120
set the loc of me to temp
unlock screen
end mouseLeave
#####END OF CODE#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Klaus
Posts: 14267
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Hot and throbbing.

Post by Klaus » Mon May 25, 2015 6:45 pm

Using the rect needs to make some calculations. I prefer this:
Yep :D

SparkOut
Posts: 2961
Joined: Sun Sep 23, 2007 4:58 pm

Re: Hot and throbbing.

Post by SparkOut » Mon May 25, 2015 7:51 pm

And what's more, this way you can also choose the direction of expansion by setting (say) the bottomRight to temp. Given the difference between the points, that will jump a little further, so put (say) the bottomRight into temp first.

Post Reply