RichTextLabel isn't Changing

Godot Version

extends Control

var CountryName = “”

@onready var text = $LineEdit.text

func _ready():

CountryName = text

$RichTextLabel.text = str(CountryName)

func _on_line_edit_text_submitted(new_event):
$RichTextLabel.text = str(CountryName)

Question

I don’t know why but the RichTextLabel isn’t changing and there’s no errors.

The behavior you want seems a little unclear, so here’s my assumption:

There is a RichTextLabel and a LineEdit. Whenever you submit (press enter) on the LineEdit, you want the RichTextLabel’s text content to become what was submitted.

If that’s the case you’re just missing a line to update that text.

func _on_line_text_submitted(new_event):
	CountryName = $LineEdit.text
	$RichTextLabel.text = CountryName

Currently $RichLabelText.text is equal to LineEdit.text during @onready, and will never change (Unless you have some other way of changing CountryName that you haven’t shown).

1 Like

ty very much

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