elgatosf / streamdeck-pisamples

Stream Deck SDK: PISamples sample plugin
https://developer.elgato.com/documentation/stream-deck/
MIT License
69 stars 27 forks source link

Initializing Radios and have it reflected in the UI #5

Closed jandolina closed 1 year ago

jandolina commented 3 years ago

This sample is kind of awesome, thank you! How do I initialize the state of the radio buttons using the JS and not the HTML?

Here is my html, lifted almost exactly from the sample code.

<div type="radio" class="sdpi-item" id="tickermode">
      <div class="sdpi-item-label">Source</div>
      <div class="sdpi-item-value ">
        <div class="sdpi-item-child">
          <input id="rdio1" type="radio" name="mytickermode" value="crypto">
          <label for="rdio1" class="sdpi-item-label"><span></span>Crypto</label>
        </div>
        <div class="sdpi-item-child">
          <input id="rdio2" type="radio" name="mytickermode" value="stocks">
          <label for="rdio2" class="sdpi-item-label"><span></span>Stocks</label>
        </div>
      </div>
    </div>

I have been working in the connectElgatoStreamDeckSocket function to preload the settings object if certain values are not found.

settings = {"tickermode":"stocks", "mynameinput":"myName"};

and

settings = {"mytickermode":"stocks", "mynameinput":"myName"};

These values make no changes to the UI. How should I set the value so that the UI is updated? What function should I call to update the UI?

tiptronic commented 3 years ago

@jandolina if you look into the the plugintemplate you will find a sample how that would work. It uses the old API, but it works fine and should give you an idea how to fill in your data.