jean-emmanuel / open-stage-control

Libre and modular OSC / MIDI controller
https://openstagecontrol.ammd.net
GNU General Public License v3.0
701 stars 88 forks source link

dropdown widget displays value instead of label #739

Closed jgastonraoul closed 3 years ago

jgastonraoul commented 3 years ago

Hi !

I'm trying to use dropdown widget, and it displays the labels in the dropdown list and the value when I select an item. Is there a way to display only the label ? (the user doesn't have to know what is the value corresponding to the item).

Another question : is there a way to change widget value only if the received value matches one of the items ? (currently, if I send something which is not in the list, the display is emptied and "undefined" is sent to the target).

jean-emmanuel commented 3 years ago

You can use the dropdown's label property:

Displayed text (defaults to current value). Keywords %key and %value will be replaced by the widget's selected key/value.

Another question : is there a way to change widget value only if the received value matches one of the items ? (currently, if I send something which is not in the list, the display is emptied and "undefined" is sent to the target).

No, but I could add an option to to ignore invalid values.

jgastonraoul commented 3 years ago

You're so quick to answer !

Thanks for the %key tip, it works like a charm !

The option to ignore invalid values would be very helpful.

One more question : is there a way to set the menu item by sending the label instead of the value ?

jean-emmanuel commented 3 years ago

Maybe by receiving the value with a script widget first and doing some parsing magic, or using a custom module, but otherwise no, the widget expects values.