colorWidget OSC listener

Hey,
when I'm listening to "OSC{/truc/1/color}" the color in the preview is well displayed but not applied to the widget, I'm receiving color as hex (eg : 04832ff)

I tried '#OSC{/truc/1/color}' which was working for some times and then stopped I guess it was a bug ?

based on that topics : Returning a certain String within a JS{ } block that calls a OSC listener even when the OSC listener hasn't received a value yet

I tried

JS{{
var col = OSC{/adm/obj/1/color};
return '#'+col+'' || white;
}}

Edit : It works seems I had a space after #, but it's not always a solution
What can I do ?

Hi Zoltan,

Hmm, I have a couple of thoughts. Have you tried the "#" shortcut, maybe it's a bug with JS{{}} return?

:host {
    background-color: #{OSC{/adm/obj/1/color} || "white"};
}

Or, you have to return "white" as a string, so you need to enclose it in quotations.

JS{{
var col = OSC{/adm/obj/1/color};
return '#'+col+'' || "white";
}}

One more thought, I believe the OSC listener as a default param you can set, so it may be safer to put this. I put the hexadecimal value of white as if it defaults to "white" and then you add a hashtag it would error out.

JS{{
var col = OSC{/adm/obj/1/color, ffffff};
return '#'+col+'' || "white";
}}

Do any of these work more consistently? I always use the first example with the shortcut "#", but I always leave a default value in the OSC listener, #{OSC{/adm/obj/1/color, #ffffff}}.

Cheers,
DMDComposer

1 Like

Thanks for you answer.

some of the solution are working pretty well, but I have pretty erratic behaviour, sometimes I'm loosing the color of the widgets.

1 Like

If you manage to make a small session file that allows reproducing this behavior please upload it.