Add signals to SuiText

Added the following signals to SuiText:
- meta_clicked
- meta_hover_started
- meta_hover_ended
This commit is contained in:
JeremyStar™ 2024-03-23 16:58:50 +01:00
parent 3f6057d745
commit d0d71e0e85
3 changed files with 21 additions and 0 deletions

View file

@ -5,6 +5,14 @@ sidebar_position: 2
# `SuiText`
Used for texts.
## Signals
### <u>meta_clicked</u>
- Signature: *Variant* <u>meta</u>
### <u>meta_hover_started</u>
- Signature: *Variant* <u>meta</u>
### <u>meta_hover_ended</u>
- Signature: *Variant* <u>meta</u>
## Variables
### *bool* <u>bbcode_support</u> = *true*
Enables or disables BBCode.

View file

@ -11,3 +11,6 @@ func _ready() -> void:
$SuiTextButton.connect("down", func() -> void: logger.info("SuiTextButton: down()"))
$SuiTextButton.connect("pressed", func() -> void: logger.info("SuiTextButton: pressed()"))
$SuiTextButton.connect("toggled", func(toggled: bool) -> void: logger.info("SuiTextButton: toggled(toggled=" + str(toggled) + ")"))
$SuiText.connect("meta_clicked", func(meta: Variant) -> void: logger.info("SuiText: meta_clicked(meta=" + str(meta) + ")"))
$SuiText.connect("meta_hover_started", func(meta: Variant) -> void: logger.info("SuiText: meta_hover_started(meta=" + str(meta) + ")"))
$SuiText.connect("meta_hover_ended", func(meta: Variant) -> void: logger.info("SuiText: meta_hover_ended(meta=" + str(meta) + ")"))

View file

@ -11,10 +11,20 @@ extends Control
@export var editor_process: bool = true
@export var runtime_process: bool = true
signal meta_clicked
signal meta_hover_started
signal meta_hover_ended
func _ready() -> void:
# Free unused children
logger.diag("<" + name + "> Freeing ToolScript")
get_child(0).queue_free()
# Add signals
logger.diag("<" + name + "> Adding signals")
$Text.connect("meta_clicked", func(meta: Variant) -> void: emit_signal("meta_clicked", meta))
$Text.connect("meta_hover_started", func(meta: Variant) -> void: emit_signal("meta_hover_started", meta))
$Text.connect("meta_hover_ended", func(meta: Variant) -> void: emit_signal("meta_hover_ended", meta))
func _process(_delta: float) -> void:
if !runtime_process: return