How to automatically scroll a TextEdit?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By picnic

I’m using a TextEdit box to add messages about what’s happening during a game as per the function below. Is it possible to automatically scroll up when adding a new message at the end to ensure the last message is visible?

func add_message(msg):
  get_node("../MessageBox").insert_text_at_cursor(msg + "\n")
:bust_in_silhouette: Reply From: ondesic

You can set the vertical_scroll to the line of text. You can find the line of text with a method in the TextEdit control. Look at the documentation for the textedit control