Questions about 'mouseEnter'

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
bogs
Posts: 3545
Joined: Sat Feb 25, 2017 10:45 pm

Questions about 'mouseEnter'

Post by bogs » Thu Aug 15, 2019 2:35 pm

I have a stack in the shape of an image with a mouseEnter routine at the stack level. I have a second image sitting on the top layer of the card, with the visible set to off.

In that image's mouseEnter, I put set the visible of me to true, but that doesn't make the image visible. I then tried using the full name of the image, like this :

Code: Select all

if the mouseLoc is within the rect of image "moveMe" then set the visible of image "moveMe" to true
but even though that works at the stack level script, it does not work with the handler in the image's script.

My thinking in moving it to the image's script was that with the image being on the top layer, if the mouse moved into the image rectangle, it should supersede the stack level script. What am I missing?
mouseEnter.png
The mouse goes in, the mouse goes out...
Image

Klaus
Posts: 11056
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Questions about 'mouseEnter'

Post by Klaus » Thu Aug 15, 2019 2:52 pm

If an object is invisible, it is also invisible for the cursor, so it does not receive any mouse messages!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6068
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Questions about 'mouseEnter'

Post by dunbarx » Thu Aug 15, 2019 3:32 pm

Hi.

A kluge might be to track the mouseLoc, testing constantly to see if it is within the rect of the invisible control. If it is, and the mouse is "down", then you can fire a handler.

Craig

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

Re: Questions about 'mouseEnter'

Post by SparkOut » Thu Aug 15, 2019 3:57 pm

Set the image to visible but with blendLevel of 99. Then it will receive mouse messages. On mouseEnter, set the blendLevel to 0, which will have the same effect as showing and hiding to a human, but a mouse can see it all the time.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6068
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Questions about 'mouseEnter'

Post by dunbarx » Thu Aug 15, 2019 5:27 pm

That is even a better kluge. Is there no perceptible difference between a blendLevel of 99 and invisible?

Craig

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

Re: Questions about 'mouseEnter'

Post by SparkOut » Thu Aug 15, 2019 5:31 pm

Not that my eyes have ever been able to discern

bogs
Posts: 3545
Joined: Sat Feb 25, 2017 10:45 pm

Re: Questions about 'mouseEnter'

Post by bogs » Thu Aug 15, 2019 7:22 pm

Klaus wrote:
Thu Aug 15, 2019 2:52 pm
If an object is invisible, it is also invisible for the cursor, so it does not receive any mouse messages!
Huh, I'd never have made that connection ImageImageImage
Thank you, I'd have driven myself nuts with that, for some reason I assumed that the engine determined the rect of an object regardless of whether it was visible or not, and could therefore tell if the cursor was over the object or not. After all, the object is still there as demonstrated by "put the rect of [object]" in the messagebox :?
dunbarx wrote:
Thu Aug 15, 2019 3:32 pm
A kluge might be to track the mouseLoc, testing constantly to see if it is within the rect of the invisible control. If it is, and the mouse is "down", then you can fire a handler.
SparkOut wrote:
Thu Aug 15, 2019 3:57 pm
Set the image to visible but with blendLevel of 99. Then it will receive mouse messages. On mouseEnter, set the blendLevel to 0, which will have the same effect as showing and hiding to a human, but a mouse can see it all the time.
Thank you both for putting me on a better track. I found the blendlevel can go all the way to 100 (literally not visible) and still works. That discovery let me re-write other code I have that works similarly, making it much more compact. Awesome.
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”