UI Dropdown, non persistent options


Hi everybody,
I have a permanent udp/osc message comming to my network, i transform it to populate the dropdown menu with a function :

var newmsg = msg;
newmsg.options = [];
var canal, value1;
for (var i = 0; i < msg.payload.length; i++) {
canal = msg.payload[i].address;
value1 = msg.payload[i].args;
newmsg.options[i] = {};
newmsg.options[i][canal] = value1;

return msg;

It works fine, the dropdown menu is correctly populate but it refresh everytime i receive a message.
(60 fps, so quite a bite often :D)

How can i manage to populate it in a constant maner in wich the label do not have to refresh everytime the value changes ?

Thanks in advance.


take a look at the RBE node aka report by exception
which can filter out messages if they are the same


Thanks for you answer.
It is working when there is no changes, but as soon as the value changes the dropdown menu get reset and i have to select again.


But if there are changes when would you expect the dropbown menu to be repopulated?


I meant values changes, not adress changes.
Here is what is my signal in oscin

In the dropdown i want to select the adress ('chan1 or chan2 ...) and the retrieve the value (args) when it changes.

But actually when the value changes the dropdown is repopulated.
I am not sure i am clear :smiley:


Trying to clarify the issue.
Are you looking for last selected value/option to be selected again after re-population occurs?


If i choose /chan1, i want to keep this chan selected when re-population happen.


You need to re-inject "chan1" as the msg.payload as well as the new msg.options - otherwise you are just injecting (nothing) - so it selects ... nothing...


When args on chan1 changes a new msg.payload is send to the dropdown, with adress and args, i would like that it keeps chan1 selected (the adress) but modifie the args associated with it.


ah right - I think you will need to do this as a function following the select - make the select just choose chan1, 2 3 etc... and then that is selected do the lookup to the value from the object you have (which could be held in context to save it)

The way the dropdown works is the value is (in your case) the args which keep changing and the displayed items to pick from are chan1 2 etc... but to preselect the item you need to set it's value - which you can't do if it has just changed.


So if i understand it right i first have to select my adress, place it in the context and then retrieve is value with a function.
Exit the dropdown then ?
I guess there is no node helping much with that no ? Have to code a function to do it right ?


yes - but most of the hard work could be done by the function that creates the dropdown options in the first place as it could also create the hashtable object at the the same time and save it in context so that then the following function would just be a simple lookup...

Of course this may mean that now the dropdown can just be a set list of chan1, 2, 3 etc if the names are now fixed... and it's now just the input that updates the hashtable object when the values change, and the output from the select that performs the lookup when selected. Of course the value then selected won't change until selected again.


That kind of the problem here, the aim is to be able to connect different osc device with different adress name. So the dropdown menu should be dynamic and the name self explanatory.
Will figure out :smiley:


Finaly i dit find a solution. (thanks to dceejay ;))
So for the one interested, i input in the dropdown menu the osc address and output also the osc adress. I declare it in a flow variable, and then compare it in a function with the incoming osc msg.
If address of the incoming = adress of the flow i take the value associated with it.
Here is the flow

[{"id":"c58a9dd2.f91e8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"5520d829.a6fd78","type":"udp in","z":"c58a9dd2.f91e8","name":"","iface":"","port":"1881","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":143.5,"y":148,"wires":[["27021ee5.78dac2"]]},{"id":"27021ee5.78dac2","type":"osc","z":"c58a9dd2.f91e8","name":"","path":"","metadata":false,"x":281.5,"y":150,"wires":[["a3a563c1.f3127","a7474af7.3673d8"]]},{"id":"a3a563c1.f3127","type":"function","z":"c58a9dd2.f91e8","name":"","func":"var newmsg = msg;\nnewmsg.options = [];\nvar value, canal;\n\nfor (var i = 0; i < msg.payload.length; i++) {\n    canal = msg.payload[i].address;\n    value = msg.payload[i].address;\n    newmsg.options[i] = {};\n    newmsg.options[i][canal] = value;\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":428,"y":146,"wires":[["caa68db4.0ff03"]]},{"id":"caa68db4.0ff03","type":"rbe","z":"c58a9dd2.f91e8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"options","x":563,"y":144,"wires":[["b13a37d8.2cb5e8"]]},{"id":"b13a37d8.2cb5e8","type":"ui_dropdown","z":"c58a9dd2.f91e8","name":"","label":"","tooltip":"","place":"Select option","group":"15dd32a9.cfc27d","order":4,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":698,"y":143,"wires":[["663b4bfb.97bdd4","28bc8e8a.c96922"]]},{"id":"a08c46d.110f1b8","type":"ui_text","z":"c58a9dd2.f91e8","group":"15dd32a9.cfc27d","order":5,"width":0,"height":0,"name":"","label":"text","format":"{{msg.valeur}}","layout":"row-spread","x":988,"y":260,"wires":[]},{"id":"663b4bfb.97bdd4","type":"debug","z":"c58a9dd2.f91e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":834,"y":78,"wires":[]},{"id":"a7474af7.3673d8","type":"function","z":"c58a9dd2.f91e8","name":"","func":"var newmsg = msg;\nnewmsg.valeur = [];\noscIn=flow.get(\"oscIn\");\nvar value, canal;\n\nfor (var i = 0; i < msg.payload.length; i++) {\n    canal = msg.payload[i].address;\n    value = msg.payload[i].args;\n\tif (canal == oscIn.payload) {\n\tnewmsg.valeur = value;\n\ti = msg.payload.length;\n} \n    else {\n        newmsg.valeur = \"select an Input\";\n    }\n}\n\n \nreturn msg;\n","outputs":1,"noerr":0,"x":616,"y":294,"wires":[["c2403dce.45ae9","a08c46d.110f1b8"]]},{"id":"28bc8e8a.c96922","type":"function","z":"c58a9dd2.f91e8","name":"","func":"flow.set(\"oscIn\", msg);\nreturn msg;","outputs":1,"noerr":0,"x":874,"y":142,"wires":[[]]},{"id":"c2403dce.45ae9","type":"debug","z":"c58a9dd2.f91e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"valeur","x":844,"y":294,"wires":[]},{"id":"15dd32a9.cfc27d","type":"ui_group","z":"","name":"Default","tab":"fb9b8517.106e88","disp":true,"width":"6","collapse":false},{"id":"fb9b8517.106e88","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]