コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        void OnSelectionToggle(PropertyElement element)
        {
            PropertySearcherItem boundSearchItem = element.Item;

            EditModel(element.Toggle.value, boundSearchItem);
        }