Making a button select a specific dropdown item

Posts: 81
Say I want to make a button that shows a widget, but also sets a specific item in a dropdown menu. Is there a way to do this?

I tried making a Dropdown action with the item I want in the 'value' textbox, but it doesn't seem to do anything since that's not its intended purpose.
Posts: 785
You can select a dropdown item via a simple script. Keep in mind that this will also trigger the actions under that dropdown item.

Replace "Dropdown1" with the name of your dropdown, and "Item text" with the text of the item you want to select.
using System;
using System.Linq;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;

namespace Scripts
{
public class SelectDropdownItemTest : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
Dropdown dropdown = item.Theme.Dropdowns.Find("Dropdown1");
DropdownItem ddItem = dropdown.Items.FirstOrDefault(i => i.Text == "Item text");

if (ddItem != null)
dropdown.SelectedItem = ddItem;

return null;
}
}
}

Edited (1 time)
Posts: 81
That did the trick, thank you!