New paste Repaste Download
func _render(ctx: Component.Context):
var list := ctx.use_array([
{ text = "a", id = _generate_unique_id(), checked = false },
{ text = "b", id = _generate_unique_id(), checked = false },
])
var list_children = []
for item_i in list.size():
var item = list.at(item_i)
list_children.append({
node_type = HBoxContainer,
size_flags_horizontal = Control.SIZE_EXPAND_FILL,
id = item.id,
children = [
{
node_type = CheckBox,
button_pressed = item.checked,
on_toggled = func(toggled_on: bool):
list.set_at(item_i, list.at(item_i).merged({ checked = toggled_on }, true)),
},
{
node_type = Button,
disabled = item_i == 0,
text = "↑",
on_pressed = func(): list.swap(item_i, item_i - 1),
},
{
node_type = Button,
text = "↓",
disabled = item_i >= list.size() - 1,
on_pressed = func(): list.swap(item_i, item_i + 1),
},
{
node_type = LineEdit,
editable = not item.checked,
custom_minimum_size = Vector2(100, 0),
size_flags_horizontal = Control.SIZE_EXPAND_FILL,
text = item.text,
on_text_changed = func(new_text):
list.set_at(item_i, list.at(item_i).merged({ text = new_text }, true)),
},
{
node_type = Button,
theme_type_variation = "RedButton",
icon = IconTexture2D.create("delete_red"),
on_pressed = func(): list.remove_at(item_i),
},
]
})
return {
node_type = VBoxContainer,
init = func(e: VBoxContainer):
e.set_anchors_and_offsets_preset(Control.PRESET_TOP_WIDE),
children = list_children + [
{
node_type = Button,
text = "+",
on_pressed = func(): list.append({
text = "newer item",
id = _generate_unique_id(),
checked = false,
}),
}
],
}
Filename: react godot.gd. Size: 2kb. View raw, , hex, or download this file.

This paste expires on 2026-07-11 07:04:05.313673+00:00. Pasted through web.