Ejemplo n.º 1
0
        public virtual bool HandleMouseClick(Vector2 ClickPosition, InputState.MouseButton ButtonType, bool bCtrlClick, bool bShiftClick, bool bDoubleClick)
        {
            if (ItemBounds.Contains(ClickPosition))
            {
                if (bInEditMode)
                {
                    // If we're in edit mode, don't handle the click event so it goes through
                    // to the text control.
                    return(false);
                }
                else
                {
                    if (ButtonType == InputState.MouseButton.Mouse_Left)
                    {
                        if (bDoubleClick)
                        {
                            HandleDoubleClick();

                            return(true);
                        }
                        else
                        {
                            if (bCtrlClick)
                            {
                                SetSelected(!bIsSelected, true);

                                return(true);
                            }
                            else if (bShiftClick)
                            {
                                // Handle shift selection

                                return(false);
                            }
                            else
                            {
                                SetSelected(true, false);

                                return(true);
                            }
                        }
                    }
                    else if (ButtonType == InputState.MouseButton.Mouse_Right)
                    {
                        Owner.ShowItemContextMenu();

                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public void ButtonEventManager(Widget focused, InputState.MouseButton button)
        {
            InputState.ButtonEvent evt = inputs.MouseButtonEvent(button);
            if ( evt == InputState.ButtonEvent.Pressed )
            {
                if (drag_button == InputState.MouseButton.None)
                {
                    drag_button = button;
                    drag_origin = inputs.pos;
                    drag_widget = focused;
                }
                //drag_widget.DragStartCallback(inputs.pos, button);
            }
            else if ( evt == InputState.ButtonEvent.Released )
            {
                if (drag_button == button)
                {
                    drag_button = InputState.MouseButton.None;

                    if (dragging)
                    {
                        dragging = false;
                        drag_widget.DragReleaseCallback(inputs.pos);
                    }
                }
                if (!dragging)
                {
                    focused.ClickCallback(inputs.pos, button);
                }
            }

            if (drag_button == button)
            {
                if ( !dragging && drag_origin != inputs.pos )
                {
                    dragging = true;
                    drag_widget.DragStartCallback(drag_origin, button);
                }
                if (dragging)
                {
                    drag_widget.DragCallback(inputs.pos);
                }
            }
        }
Ejemplo n.º 3
0
        public virtual void CheckForMouseEvents()
        {
            if (!bWindowHasFocus)
            {
                return;
            }

            Vector2 ClickPosition = InputState.GetLocalMousePosition(this, new Vector2(0.0f, 40.0f));
            bool    bHandleClick  = false;

            InputState.MouseButton ButtonType = InputState.MouseButton.Mouse_Left;

            if (Event.current.type == EventType.MouseDrag)
            {
                for (int CurrentItem = 0; CurrentItem < ListItems.Count; ++CurrentItem)
                {
                    if (ListItems[CurrentItem].IsWithinBounds(ClickPosition) &&
                        !ListItems[CurrentItem].IsInEditMode())
                    {
                        DragAndDrop.PrepareStartDrag();

                        List <string> Paths = new List <string>();
                        Paths.Add(ListItems[CurrentItem].GetDragAndDropText());
                        DragAndDrop.paths = Paths.ToArray();

                        DragAndDrop.StartDrag(ListItems[CurrentItem].GetDisplayText());

                        Event.current.Use();
                    }
                }
            }
            else if (!InputState.IsMouseButtonDown(InputState.MouseButton.Mouse_Left) &&
                     !InputState.WasLastMouseUpHandled(this, InputState.MouseButton.Mouse_Left))
            {
                bHandleClick = true;
                ButtonType   = InputState.MouseButton.Mouse_Left;
            }
            else if (!InputState.IsMouseButtonDown(InputState.MouseButton.Mouse_Right) &&
                     !InputState.WasLastMouseUpHandled(this, InputState.MouseButton.Mouse_Right))
            {
                bHandleClick = true;
                ButtonType   = InputState.MouseButton.Mouse_Right;
            }

            if (bHandleClick)
            {
                bool bCtrl        = InputState.IsModifierDown(InputState.ModifierKeys.Key_Control);
                bool bShift       = InputState.IsModifierDown(InputState.ModifierKeys.Key_Shift);
                bool bDoubleClick = InputState.WasLastClickDoubleClick(ButtonType);

                bool bClickHandled = false;

                for (int CurrentItem = 0; CurrentItem < ListItems.Count; ++CurrentItem)
                {
                    if (ListItems[CurrentItem].IsWithinBounds(ClickPosition))
                    {
                        bClickHandled = true;

                        if (ListItems[CurrentItem].HandleMouseClick(ClickPosition, ButtonType, bCtrl, bShift, bDoubleClick))
                        {
                            GUIUtility.keyboardControl = 0;

                            InputState.HandledMouseUp(ButtonType);

                            if (bDoubleClick)
                            {
                                InputState.HandledDoubleClick(ButtonType);
                            }

                            break;
                        }
                    }
                }

                if (!bClickHandled)
                {
                    if (ButtonType == InputState.MouseButton.Mouse_Left)
                    {
                        ClearSelection();
                        SetAllToViewMode();
                    }
                    else if (ButtonType == InputState.MouseButton.Mouse_Right)
                    {
                        ShowNoSelectionContextMenu();
                    }
                }
            }
        }