Set or Update widget properties from Custom Module?

Is it possible to set or update a widget's properties from the Custom Module?

For example, if I have incoming messages from a third-party resource, I want to listen for a message and update OSC's widget properties accordingly. A simple case would be updating the colorWidget property to change the background, update the widget's entire CSS, or change the mode of the button?

Cheers,
DMDComposer

Hello,

Yes, you can do it using OSC{} messages in conjunction with a custom module.
Let's stick with changing a button color example, for this demonstration.
I have set the colorWidget prop of a button to this:

//btn_1 is the OSC address and it's default value is "lime"
OSC{/btn_1, lime} 

Now, in the custom module oscInFilter:

oscInFilter: function (data) {
    const { address, args, host, port } = data
    //checks for the CC 1 messages coming from the MIDI port "oscMIDI"
    if (port == "oscMIDI" && address === "/control" && args[0].value === 1 ) {
    // if CC1 values are greater than 64, set the button's color to red
        if (args[2].value > 64) {
             receive("/btn_1", "red")
        }
    // otherwise, sets it back to lime
        else {
             receive("/btn_1", "lime")
        }
    }
}

I hope it helps.
Cheers

1 Like

Thank you Clelson! That's exactly what I was looking for with a perfect example to follow.

Cheers,
DMDComposer

1 Like