public override VisualElement MakeItem() { // create a visual element hierarchy for this search result PropertyElement item = new PropertyElement(m_ItemTemplate.name); m_ItemTemplate.CloneTree(item); item.Toggle = item.MandatoryQ <Toggle>("selectionToggle"); item.Toggle.RegisterValueChangedCallback(e => OnSelectionToggle(item)); return(item); }
public override VisualElement Bind(VisualElement element, SearcherItem item, ItemExpanderState expanderState, string query) { var propItem = (PropertySearcherItem)item; VisualElement expander = base.Bind(element, item, expanderState, query); PropertyElement propElt = (PropertyElement)element; propElt.Item = propItem; propItem.Element = propElt; Toggle toggle = propElt.Toggle; // SetValueWithoutNotify sets the value, but not the pseudostate toggle.SetValueWithoutNotify(propItem.Enabled); // .value= will set the pseudo state, but skip the notify and the markDirtyRepaint, as newValue == oldValue toggle.value = (propItem.Enabled); // still needed toggle.MarkDirtyRepaint(); return(expander); }
void OnSelectionToggle(PropertyElement element) { PropertySearcherItem boundSearchItem = element.Item; EditModel(element.Toggle.value, boundSearchItem); }