예제 #1
0
파일: GuiView.cs 프로젝트: Rahil627/Rise
        //TODO: Maybe user should send these events to the view manually,
        //that way they'd be able to pick and choose/control its input.
        //They could also "simulate" interacting with UI, which would be cool.
        public void Update()
        {
            bool hoverPrev = MouseOverPrev;
            bool hoverCurr = MouseOver;

            if (Mouse.Position != Mouse.LastPosition)
            {
                DoMouseMove();
                Dragging?.DoDragUpdate();
            }

            if (hoverCurr)
            {
                if (Mouse.LeftPressed)
                {
                    DoMouseDown(MouseButton.Left);
                    Dragging?.DoDragStart();
                }
                else if (Mouse.MiddlePressed)
                {
                    DoMouseDown(MouseButton.Middle);
                }
                else if (Mouse.RightPressed)
                {
                    DoMouseDown(MouseButton.Right);
                }

                if (Mouse.LeftReleased)
                {
                    DoMouseUp(MouseButton.Left);
                    Dragging?.DoDragEnd();
                    DoDrop(Dragging);
                    Dragging = null;
                    leftClick?.DoClick(MouseButton.Left);
                    leftClick = null;
                }
                else if (Mouse.MiddleReleased)
                {
                    DoMouseUp(MouseButton.Middle);
                    middleClick?.DoClick(MouseButton.Middle);
                    middleClick = null;
                }
                else if (Mouse.RightReleased)
                {
                    DoMouseUp(MouseButton.Right);
                    rightClick?.DoClick(MouseButton.Right);
                    rightClick = null;
                }

                if (Mouse.Scroll != Point2.Zero)
                {
                    DoScroll();
                }
            }

            OnUpdate?.Invoke();
        }
예제 #2
0
        internal override void DoDrop(GuiElement elem)
        {
            base.DoDrop(elem);

            if (MouseEnabled && MouseChildren)
            {
                foreach (var child in Children)
                {
                    if (child.Enabled && child.MouseOver)
                    {
                        child.DoDrop(elem);
                    }
                }
            }
        }
예제 #3
0
 internal virtual void DoDrop(GuiElement elem)
 {
     OnDrop?.Invoke(elem);
 }