Resizing a frame "shifts" it's contents

I am creating a tooltip system that shows a tooltip when the mouse is hovered over a specific frame. The tooltip is automatically being resized based on the text, using this code:

tooltip.label.Text = tooltipText.Value
local abssize = tooltip.label.TextBounds
local abssize = UDim2.fromOffset(abssize.X, abssize.Y)
size = abssize + UDim2.fromOffset(5, 5)
tooltip.label.Size = abssize
tooltip.Size = size

(I know about the AutomaticSize property, though I want more control over the resizing)

The issue: resizing a frame causes it’s contents to “shift” in the direction resized. This happens also when scripting it as well as in Studio.

Watch the “Label” text in the gif as it moves when I resize the parent frame.
RobloxStudioBeta_FGGp4coIPC

This also happens vertically: I expect the label text to stay in the top left corner
RobloxStudioBeta_3fQWDs0jfC

Here is how the frame is structured
RobloxStudioBeta_UHGoFk2Vw9

I have already tried setting AnchorPoint of both the frame and the label to (0.5, 0.5), as well as (0, 0)

This is because the text has it’s position or scale set in scale. You can fix this for both by setting the position and the anchor point property of the text labels to 0,0. To add some seperation between the two you can use UIPadding with offsets.

This is not a bug.

AnchorPoint just changes where the center (or the “position offset”) of the Frame will be, always starting out at 0,0 (which is the Top Left Corner), so that wouldn’t do much.


If you are referring to the size of the frame (The Text Frame), then a solution would be to use a hybrid of Scale, and Offset sizing. So rather than a fixed size in pixels, or a percentage of space taken at a time. you can give it the scale portion a value of (1, 1), which would cover 100% of the parent Frame. Then set the Offset portion to be something like (-5, 0) or (-5, -5) to maintain a “indent” of the text.

You can then use AnchorPoint to center the Frame to the center of the parent Frame, using scale position (0.5, 0.5)
What this will do is always have a 5 pixel offset from the parent Frame no matter the size due to the scale sizing.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.