Skip to content

Commit 3ce73e5

Browse files
committed
Merge pull request #86331 from Calinou/doc-richtexteffect
Improve RichTextLabel `install_effect()` documentation
2 parents fc082dd + 78fff72 commit 3ce73e5

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

doc/classes/RichTextEffect.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
A custom effect for a [RichTextLabel].
55
</brief_description>
66
<description>
7-
A custom effect for a [RichTextLabel].
7+
A custom effect for a [RichTextLabel], which can be loaded in the [RichTextLabel] inspector or using [method RichTextLabel.install_effect].
88
[b]Note:[/b] For a [RichTextEffect] to be usable, a BBCode tag must be defined as a member variable called [code]bbcode[/code] in the script.
99
[codeblocks]
1010
[gdscript skip-lint]

doc/classes/RichTextLabel.xml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,28 @@
225225
<return type="void" />
226226
<param index="0" name="effect" type="Variant" />
227227
<description>
228-
Installs a custom effect. [param effect] should be a valid [RichTextEffect].
228+
Installs a custom effect. This can also be done in the RichTextLabel inspector using the [member custom_effects] property. [param effect] should be a valid [RichTextEffect].
229+
Example RichTextEffect:
230+
[codeblock]
231+
# effect.gd
232+
class_name MyCustomEffect
233+
extends RichTextEffect
234+
235+
var bbcode = "my_custom_effect"
236+
237+
# ...
238+
[/codeblock]
239+
Registering the above effect in RichTextLabel from script:
240+
[codeblock]
241+
# rich_text_label.gd
242+
extends RichTextLabel
243+
244+
func _ready():
245+
install_effect(MyCustomEffect.new())
246+
247+
# Alternatively, if not using `class_name` in the script that extends RichTextEffect:
248+
install_effect(preload("res://effect.gd").new())
249+
[/codeblock]
229250
</description>
230251
</method>
231252
<method name="is_menu_visible" qualifiers="const">

0 commit comments

Comments
 (0)