How to position a draw call behind the main text ( RichTextLabel )?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wombatTurkey
:warning: Old Version Published before Godot 3 was released.

Hey everyone!

I’m creating a diablo style chat box and am curious if it’s possible to draw a background color behind a richt text label.

Infact, here is the script applied to my RichTextLabel:

extends RichTextLabel

func _ready():

func _draw():
	var r = Rect2( Vector2(0, 0), get_size() )
	draw_rect(r, Color(0, 0, 0, 1) )
	print("drawing for my rtl")

This actually draws the black background, but it draws it infront of the text.

enter image description here

I’m curious, is it possible to somehow re-order the draw order on a RichTextLabel, so the background is behind the text instead?

You could have another background node above your text in the scene tree, but it requires you to have two nodes for this.

Zylann | 2016-05-28 11:11

Yeah @zylann I figured I’d just do a separate background panel behind the RTL, works fine, thx!

wombatTurkey | 2016-05-29 02:20