Пример #1
0
        public void HandleUnusedMouseEventsForItem(Rect rect, TreeViewItem item, int row)
        {
            int       itemControlID  = TreeViewController.GetItemControlID(item);
            Event     current        = Event.current;
            EventType typeForControl = current.GetTypeForControl(itemControlID);

            switch (typeForControl)
            {
            case EventType.MouseDown:
                if (rect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.button == 0)
                    {
                        GUIUtility.keyboardControl = this.m_KeyboardControlID;
                        this.Repaint();
                        if (Event.current.clickCount == 2)
                        {
                            if (this.itemDoubleClickedCallback != null)
                            {
                                this.itemDoubleClickedCallback(item.id);
                            }
                        }
                        else
                        {
                            List <int> newSelection = this.GetNewSelection(item, true, false);
                            bool       flag         = this.dragging != null && newSelection.Count != 0 && this.dragging.CanStartDrag(item, newSelection, Event.current.mousePosition);
                            if (flag)
                            {
                                this.m_DragSelection = newSelection;
                                DragAndDropDelay dragAndDropDelay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), itemControlID);
                                dragAndDropDelay.mouseDownPosition = Event.current.mousePosition;
                            }
                            else
                            {
                                this.m_DragSelection.Clear();
                                if (this.m_AllowRenameOnMouseUp)
                                {
                                    this.m_AllowRenameOnMouseUp = (this.state.selectedIDs.Count == 1 && this.state.selectedIDs[0] == item.id);
                                }
                                this.SelectionClick(item, false);
                            }
                            GUIUtility.hotControl = itemControlID;
                        }
                        current.Use();
                    }
                    else if (Event.current.button == 1)
                    {
                        bool keepMultiSelection = true;
                        this.SelectionClick(item, keepMultiSelection);
                    }
                }
                return;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == itemControlID)
                {
                    bool flag2 = this.m_DragSelection.Count > 0;
                    GUIUtility.hotControl = 0;
                    this.m_DragSelection.Clear();
                    current.Use();
                    if (rect.Contains(current.mousePosition))
                    {
                        Rect       renameRect  = this.gui.GetRenameRect(rect, row, item);
                        List <int> selectedIDs = this.state.selectedIDs;
                        if (this.m_AllowRenameOnMouseUp && selectedIDs != null && selectedIDs.Count == 1 && selectedIDs[0] == item.id && renameRect.Contains(current.mousePosition) && !EditorGUIUtility.HasHolddownKeyModifiers(current))
                        {
                            this.BeginNameEditing(0.5f);
                        }
                        else if (flag2)
                        {
                            this.SelectionClick(item, false);
                        }
                    }
                }
                return;

            case EventType.MouseMove:
IL_2C:
                if (typeForControl == EventType.DragUpdated || typeForControl == EventType.DragPerform)
                {
                    bool firstItem = row == 0;
                    if (this.dragging != null && this.dragging.DragElement(item, rect, firstItem))
                    {
                        GUIUtility.hotControl = 0;
                    }
                    return;
                }
                if (typeForControl != EventType.ContextClick)
                {
                    return;
                }
                if (rect.Contains(current.mousePosition))
                {
                    if (this.contextClickItemCallback != null)
                    {
                        this.contextClickItemCallback(item.id);
                    }
                }
                return;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == itemControlID && this.dragging != null && this.m_DragSelection.Count > 0)
                {
                    DragAndDropDelay dragAndDropDelay2 = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), itemControlID);
                    if (dragAndDropDelay2.CanStartDrag() && this.dragging.CanStartDrag(item, this.m_DragSelection, dragAndDropDelay2.mouseDownPosition))
                    {
                        this.dragging.StartDrag(item, this.m_DragSelection);
                        GUIUtility.hotControl = 0;
                    }
                    current.Use();
                }
                return;
            }
            goto IL_2C;
        }