Ejemplo n.º 1
0
        VisualElement MakeItem()
        {
            var box = new VisualElement();

            box.AddToClassList(k_TreeItemClassName);
            m_Dragger?.RegisterCallbacksOnTarget(box);

            if (m_TooltipPreview != null)
            {
                box.RegisterCallback <MouseEnterEvent>(OnItemMouseEnter);
                box.RegisterCallback <MouseLeaveEvent>(OnItemMouseLeave);
            }

            var label = new Label();

            label.AddToClassList(k_TreeItemLabelClassName);

            box.Add(label);

            // Open button.
            var openButton = new Button()
            {
                name = k_OpenButtonClassName, text = "Open"
            };

            openButton.AddToClassList(BuilderConstants.HiddenStyleClassName);
            openButton.clickable.clickedWithEventInfo += OnOpenButtonClick;
            box.Add(openButton);

            return(box);
        }
        protected void RegisterControlContainer(VisualElement element)
        {
            m_Dragger?.RegisterCallbacksOnTarget(element);

            if (m_TooltipPreview != null)
            {
                element.RegisterCallback <MouseEnterEvent>(OnItemMouseEnter);
                element.RegisterCallback <MouseLeaveEvent>(OnItemMouseLeave);
            }
        }