Hello,
I have a lot of widgets and to save and record configuration I want to speed up differently.
List of all widgets in the program I write down.
for w in pairs(viewbuilder.views) do
rprint(w)
end
So in Views I have individual widgets stored.
class: ValueBox
properties:
active
height
max
midi_mapping
min
steps
tooltip
value
visible
width
methods:
__STRICT
add_child
add_notifier
remove_child
remove_notifier
But to be able to work with it as I need, I need to find out his defined ‘ID’ that I gave him when creating.
Is it possible?
Thanks
EDIT:
And same for data created with renoise.Document.create(‘test’)
How i print keys and values ?
local vb = renoise.ViewBuilder()
local button = vb:button { id = "my_button" }
local checkbox = vb:checkbox { id = "my_checkbox" }
function find_view_id(vb, view_object)
for id, view in pairs(vb.views) do
if rawequal(view, view_object) then
return id
end
end
end
print(find_view_id(vb, checkbox))
print(find_view_id(vb, button))
Summary
PS. I stay as far away from view id:s as possible. They do not feel as part of a healthy design pattern imo, but an ad-hoc feature to cater to beginner needs. I cannot think of one case where their use is part of a well structured code.
Thanks,
it’s out of laziness.
My gui code is long and I don’t have every important widget in a separate variable. ‘id’ is the easy way for me.
When uploading the configuration, I just want to pass the data from the configuration and if the key from the configuration matches the ‘id’ of the widget, it will automatically put a value in it. This could be done in one short cycle rather than assigning each value separately.
Pseudocode:
for key in Config.keys() do
result = check_if_same_id_is_in_widgets(key)
if result then
widget.value = key.value
end
end