Documents Notifiers

Hello

Say I have two document objects, and a variable that points to one of them.

Then I have a viewbuilder textfield that is bound to the variable.

If I change the variable to point to the other document, the textfield is not updated.

Is is supposed to be like that or am I doing something wrong? Can I force the document to call all notifiers/bindings

Example code, not executable, just to illustrate what I’m trying to say:

  
doc1 = renoise.Document.create("Doc") {  
 my_value = "Hello"  
}  
doc2 = renoise.Document.create("Doc") {  
 my_value = "Goodbye"  
}  
doc_ref = doc1  
  
vb:textfield {  
 bind = doc_ref.my_value  
}  
  
doc_ref = doc2 --Textfield not changed  
  

Cheers
F

What does happen if you would do this?:
doc_ref.value = doc2.value
i thought doc_ref and doc2 are defined as functions after creation and not tables, but you can be sure by oprint or rprint the doc_ref in the terminal.

Yo

Thanks, but sorry no value.

  
class: DocumentNode  
 methods:  
 __STRICT  
 __init  
 __resolve_property__  
 add_properties  
 add_property  
 load_from  
 property  
 remove_property  
 save_as  
  

I’ve done a little more testing.

It seems like the UI elements are allways bound to doc1 that was the document the variable pointed to when it was initially bound.

If i do

  
doc_ref = doc2  
doc_ref:load_from("xxx")  
  
doc_ref = doc1  
doc_ref:load_from("xxx")  
  

the UI elements only get the values updated when doc_ref points to doc1.

So, noone?

Am I thinking the wrong way?

I want to have a set of UI elements that are bound to document variables and I want to be able to switch between different documents, but not by loading from an xml file.

Do I need to manually copy every value? If so, is there no way to loop trough the document variables? Do I need explicitly say doc_ref.my_value.value = doc1.my_value.value for each property?

Thanks in advance
CB

I remember something along the lines of “must set each value separately” being hinted at in the past. If so, all I can think of for looping through the values is to have a reference table for the keys to set. To elaborate on this speculation with some UNTESTED Lua:
If your document table is setup so:

  
local doc = renoise.Document.create("Doc") {  
 my_value = "Hello"  
 my_other_value = "World"  
 my_yet_another_value = "Foobar"  
}  
  

You could perhaps set up a ref table like so:

  
local doc_new_values = {  
 ["my_value"] = "Not hello",  
 ["my_other_value"] = "Not world",  
 ["my_yet_another_value"] = "Not foobar",  
}  
  

and set the values with a loop like so:

  
for set_key, set_value in pairs(doc_new_values) do  
 doc.set_key.value = set_value  
end  
  

If that works, you could probably wrap that in a convenient function, too. This could be a bit oversimplified, or maybe won’t apply to your situation, but maybe this helps…

Thanks.

Well, I want the file serialization of both the documents and I want the notifiers/bindings to the UI.

Arrgh, what the heck I’ll make a function that copies value by value. Will only take me 5 minutes of some copy/paste manoovers.

Only problem is that repetitive code is ugly, but I can live with that :slight_smile:

CB