How can i make a dialog button be active or deactivated using hooks? I know they only work with components, but how could i make them work with dialog buttons as well?
This is the code:
local function toggle(n, v)
return v
end
local can_create, set_can_create = editor.ui.use_state(true)
local result = editor.ui.show_dialog(editor.ui.dialog({
title = "Unfold",
content = editor.ui.grid({
padding = editor.ui.PADDING.LARGE,
columns = { {}, { grow = true } },
children = {
{
editor.ui.label({
text = "Configuration File",
alignment = editor.ui.ALIGNMENT.RIGHT
}),
editor.ui.resource_field({
title = "Select Configuration file",
extensions = { "lua" },
on_value_changed = function(path)
if path then
config_path = path
set_can_create(toggle, true)
else
set_can_create(toggle, false)
end
end
})
}
}
}),
buttons = {
editor.ui.dialog_button({
text = "Quick Configuration Setup",
result = "config",
}),
editor.ui.dialog_button({
text = "Create Collection",
result = "created",
default = true,
enabled = can_create
}),
}
}))