Using Dyalog APL I'm trying to create a grid with cell tooltips. These tooltips are created with the method AddComment. For some reason the tooltip does not resize itself to fit the content so if the text doesn't fit it will be cut off. Therefor a size calculation is required before the tooltip is created. The method GetTextSize can be used to retrieve the size of a text in pixels for the used font. However, this method seems to report the wrong size despite setting the Coord property to 'Pixel'.
Here is an example which illustrates the problem:
∇ ShowGrid;col;comment;height;row;width
'F'⎕WC'Form'
'F.G'⎕WC'Grid'(2 2⍴0)(0 0)(100 100)
comment←↑'line one' 'line two' 'line three'
row col←1 2
'F.G' ⎕WS'Coord' 'Pixel'
height width←4+F.G.GetTextSize comment
F.G.AddComment row col comment height width
∇
I also add four pixels to the reported size of the text since the border and padding of the tooltip seems to be one pixel each. The window created with this function is shown in the image below. Only the text "line one" is visible in the tooltip. I also tried setting Coord to 'RealPixel' and 'ScaledPixel' respectively but it made no difference. My question is basically: What is the proper way to calculate the tooltip size so that any given text will be displayed in its entirety? I'm using Dyalog APL 16.0 Classic.