[Newbies] Modifying tooltips in Squeak

Jerome Peace peace_the_dreamer at yahoo.com
Fri Jan 27 20:33:43 UTC 2012

MJK wrote:
> I also
> don't understand where the tooltip gets those polygon coordinates that shape
> the balloon.
[Newbies] Modifying tooltips in Squeak

>As far as I can tell it is in
>BalloonMorph class getVertices:

>Hope that helps, David

It starts with the boundry for the text morph which is a rectangle.

Sending the message #corners to the rectangle gets you four vertices. They need to be arranged in a certain order.
Then you add a few more to get the speech tail. Those become vertices for a smooth curve polygon. Then you have to figure where to put the text morph inside the polygon. The way balloon morph uses is #adjustedCenter which isolates the four rectangle vertices and takes the average. The center of the text morph is aligned with that point. 

Getting the curve to look good gets a little tricky because the polygon is working on being a smooth curve. If you are willing to use a rectangular looking tool tip you could use a segmented polygon and gain more control over the shape at the cost of having to generate all the extra vertices yourself. 

Basically the tool tip boundry is just some function of the corners of the text morph boundry and where you want the speech tail.

A good way to play would be to subclass the BalloonMorph and modify the #initialize #getVertices and #adjustedCenter methods.


Yours in curiosity and service, Jerome Peace

More information about the Beginners mailing list