To use the custom mode you have to switch the column of the TreeItem to CELL_MODE_CUSTOM
mode and provide a custom render callback by calling set_custom_draw
for every TreeItem
var tree = Tree.new()
var item = tree.create_item()
item.set_cell_mode(0, CELL_MODE_CUSTOM)
item.set_custom_draw(0, callbackHolder, "customDraw")
# this method must be in the callbackHolder
func customDraw(item, rect):
tree.draw_rect(rect, Color.new(1,1,1)) # draws your color as cell's background
In this method you may use drawing methods from this tutorial.
https://docs.godotengine.org/en/stable/tutorials/2d/custom_drawing_in_2d.html
It is important to call the draw_something
method on the Tree object, not on the callback holder itself. Any Godot's object may be used as a callbackHolder.