Customizing with States
Saturday, March 27, 2021
Widget's attributes and their Customize Panel settings are connected by share_attribute_with_element(). These connections can also be destroyed with unshare_attribute_with_element().
The Customize Panel functions that build Customize Setting Widgets (CSW, formerly Attribute Widgets) currently shares only the 'Default' attributes with their controls. The share and unshare functions need a way for the developer to specify the state of the attribute they wish to (un)share.
When the CSW is built, it will first connect the controls to whichever state appears first in the widget's state list; the combobox would be initialized to the first state by default. The controls then need to connect to the set of attributes associated with whichever state the user specifies with the combobox (Basically, in the combobox's changed_state() function, you want to reset the controls accordingly, likely using lambda).