Image as Tooltip?

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

Post Reply
cmhjon
Posts: 43
Joined: Tue Aug 04, 2015 11:55 am

Image as Tooltip?

Post by cmhjon » Fri Jul 06, 2018 6:15 pm

Hi all,

When I hover my house over an object (I am guessing the object would have a 'mouseWithin' handler), I would like for a small image to appear...sort of like a tooltip. There are approximately 20 different objects on one card each needing a separate image 'tooltip'.

Suggestions/code examples on how to achieve this?

Thank you,
Jon :)

mrcoollion
Posts: 322
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Image as Tooltip?

Post by mrcoollion » Fri Jul 06, 2018 7:44 pm

Maybe you can create a small transparent substack with a changeable image on it and let it show and hover as soon as you mouse is within an object?

Good luck,

Paul

cmhjon
Posts: 43
Joined: Tue Aug 04, 2015 11:55 am

Re: Image as Tooltip?

Post by cmhjon » Fri Jul 06, 2018 7:51 pm

Hi Paul,

That's exactly what I did. I have a sub stack with multiple cards. Each card contains an image. Back on the main stack, each object contains mouseEnter and mouseLeave handlers with the mouseEnter handler pointing to a particular card of the sub stack.

Thanks so much,
Jon

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2209
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Image as Tooltip?

Post by jmburnod » Fri Jul 06, 2018 7:57 pm

Hi Jon,
You may use a group with an image or just one image which is visible on mouseenter at the loc of your object or where you want.
You may change image filename or text according to your object
Best regards
Jean-Marc

trinitylogics
Posts: 7
Joined: Mon Jul 02, 2018 4:17 am

Re: Image as Tooltip?

Post by trinitylogics » Fri Jul 06, 2018 11:19 pm

You might want to try using an "on mouseMove" at the card level.

Code: Select all

on mouseMove
   local tObj
   put the short name the mouseControl into tObj
   if exists(img tObj of stack "iconStack") then
      [show the stack with the correct image]
   end if
end mouseMove
Gets a bit more complex if you have grouped objects, but at least every control will not need a mouseEnter, mouseLeave command.

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

Re: Image as Tooltip?

Post by dunbarx » Sat Jul 07, 2018 4:03 am

All good suggestions. Try this, Make a few buttons and import an image. Set the rect of the image to 10x10 and lock its loc. In the card script:

Code: Select all

on mouseMove x,y
   if the mouseloc is within the rect of btn 1 then show img 1 at (x + 20) & "," & y
end mouseMove
You can create a schema where the name (or number or whatever property you want) of the target is used instead of the explicit reference above, and show the image of choice, hiding all the others.

Craig Newman

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2209
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Image as Tooltip?

Post by jmburnod » Mon Jul 09, 2018 7:42 pm

Hi All,
Here is a simple stack to compare mouseenter/mousemove for this case.
stToolTipImage01.zip
(21.98 KiB) Downloaded 3 times
1. by MouseEnter script behavior and mouseenter in cd script
2. by Mousemove script behavior and mouseenter in cd script
Both need a grc "TrapMouseenter" which send mouseenter catched by mouseenter cd script to hide the image.
The "image tooltip" get the text of an hidden image (one for each btn).
You may set the behavior of btn with radio buttons.
Best
Jean-Marc

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”