Intro to Text
Text elements in gooey are labels that can be created to display text in panels.
Constructor
Text elements are created by using the UIText constructor, which has the following signature:
Here:
idis the string ID.xandyare the offsets with respect to the anchor point.textis the ScribbleDX string (with optional inline tags).relative_tois the anchor point, as usual from theUI_RELATIVE_TOenum.
Styles
In gooey, UIText widgets support regular, mouseover and click text strings. This means you can change the format (and even the text!) on each of those three events:
| Event | Method |
|---|---|
| Regular (no event) | setText |
| Mouseover | setTextMouseover |
| Left Click | setTextClick |
UIText
Please note that these behaviors are only supported starting with gooey 2025.4.
You can also set up background formatting. This will cause gooey to render a small, colored rectangle below the text. You can set this up using setBackgroundColor and setBackgroundAlpha. By default, there's no color (-1), so only the text renders.
Text formatting
As described in the Working with Text in gooey article, text formatting relies on ScribbleDX interpreting inline tags. For UIText elements, prior to 2025.11 there is no separate format string variables - you directly specify inline tags in the text string. However, starting on that version, you do have text formatting prefix tags for each of the three states, for added flexibility. Review the documentation mentioned above, and the official ScribbleDX documentation, to know more about these tags.
Text wrapping
You can also set up wrapping by configuring a maximum width, by using setMaxWidth. This will cause ScribbleDX to use wrapping when rendering the text.
Typists
UIText elements can use a typist to emulate a typewriter effect. You can configure the typist as usual in a game object, and then link to that typist by using setTypist. This allows you to animate text in a panel directly according to that effect.
Examples
I created an example with several UIText elements configured with different tags. The code is the following (note that, for brevity, I'm skipping the panel and grid codes, as well as the line that adds each UIText element to the grid):
The above code yields the following interactive example: