# Can the position of Tooltips be changed?

Is it possible to change the position of tool tips, which currently always appear to the lower right of the mouse position. In the screen grab below the mouse is over 10000000 and the tooltip appears to the bottom right (8.0.4 on Mac).

By way of an example how would you go about making the tooltip appear to the bottom left (courtesy of photo editing):

(This was originally asked on StackOverflow, but it did not draw any answers.)

-
We'll see if this draws answers here. –  rcollyer Feb 2 '12 at 3:31
On my system (Mathematica 8.0.1 Linux x64) the tooltip is displayed at the mouse position, not necessarily at the bottom right. –  David Z Feb 2 '12 at 6:46
thanks @David. Just added an edit: my system is Mac. I wonder if that means that the position is something that Mma takes from the operating system. –  Mike Honeychurch Feb 2 '12 at 6:51
It's easy to get the tooltip to come up to the left of the cursor; position your content along the right edge of your screen... ;-) –  Brett Champion Mar 6 '12 at 1:26
Sorry, if it's a real tooltip, the answer is just simply no. Can't be done. The positioning algorithm is hard-coded into the FE source code (I just checked) and is not user-settable. You might be able to find some way to create a fake tooltip-like thing which you can have more control over, but it's just not going to be possible with the real thing. FWIW, you're the first person I'm aware of to ask for this functionality. Wasn't even on my radar before. –  John Fultz Mar 6 '12 at 4:12

Improvised Tooltip using Text and Mouseover

Here's one way to improvise a tooltip for graphics objects--in this case, a list of points. It emulates a tooltip but does not leave a a drop shadow, and as István notes, has a few graphical shortcomings that make it less than ideal (clipping, under axes layer). Also, the code would need to be tweaked for objects displayed through functions other than Graphics.

[Edit: The present version makes use of Heike's suggestion to use the third parameter of Text for the offset. As Heike notes, "The units of the third argument of Text are scaled with respect to the bounding box of the first argument where {0,0} corresponds to the centre, {-1,-1} to the lower left corner, {1,1} to the upper right corner etc."]

Graphics[{PointSize[Medium],
Table[Mouseover[Point[p], {Point[p],
Text[Framed[p, Background -> LightYellow], p, {1.25, 2}]}],
{p, RandomReal[1, {10, 2}]}]}, Frame -> True,
PlotRange -> {{0, 1}, {0, 1}}, ImagePadding -> {{100, 10}, {50, 5}}]


-
You could use the third argument of Text for the vertical displacement as well, for example Text[Framed[p, Background -> LightYellow], p, {1.2, 1}]. This would make the relative position of the label independent of the plot range of the plot. –  Heike Mar 8 '12 at 10:07
Thanks. I figured out how to use Scaled. What units does your adjustment use? They are not the same as scaled. Nor are they printer's points. –  David Carraher Mar 8 '12 at 10:24
It looks like the third argument of Text uses characters (in the current font size) as units. If so, that is a nice alternative to Scaled. –  David Carraher Mar 8 '12 at 10:32
The units of the third argument of Text are scaled with respect to the bounding box of the first argument where {0,0} corresponds to the centre, {-1,-1} to the lower left corner, {1,1} to the upper right corner etc. –  Heike Mar 8 '12 at 10:51
While this is a really nice solution, showing how to improvise if reverse engineering is not available, it has some drawbacks: 1) tooltips are layered behind the axes/frames, 2) they are clipped at the edges, 3) they are not drawn using the generic functions of the OS, thus this tooltip won't look like standard tooltips on e.g. a Mac. –  István Zachar Mar 8 '12 at 11:52