Beispiel #1
0
        public virtual void UpdateInput(InputManager input)
        {
            if (Enabled && GlobalIntersection != Rectangle.Empty)              // && !GuiManager.MouseRecieved) {
            {
                var currentMousePoint = new Point(input.MouseState.X, input.MouseState.Y);
                var lastMousePoint    = new Point(input.LastMouseState.X, input.LastMouseState.Y);

                if (GlobalIntersection.Contains(currentMousePoint) && !GuiManager.MouseRecieved)
                {
                    ContainsMouse = true;
                    if (!GlobalIntersection.Contains(lastMousePoint))
                    {
                        if (MouseEntered != null)
                        {
                            MouseEntered.Invoke(this, EventArgs.Empty);
                        }
                    }

                    if (RecievesMouse)
                    {
                        GuiManager.MouseRecieved = true;
                    }
                }
                else
                {
                    ContainsMouse = false;
                    if (GlobalIntersection.Contains(lastMousePoint))
                    {
                        if (MouseExited != null)
                        {
                            MouseExited.Invoke(this, EventArgs.Empty);
                        }
                    }
                }

                if (ContainsMouse)
                {
                    if (input.IsMousePressed(MouseButton.Left))
                    {
                        if (LeftClicked != null)
                        {
                            LeftClicked.Invoke(this, EventArgs.Empty);
                        }
                    }
                    if (input.IsMousePressed(MouseButton.Middle))
                    {
                        if (MiddleClicked != null)
                        {
                            MiddleClicked.Invoke(this, EventArgs.Empty);
                        }
                    }
                    if (input.IsMousePressed(MouseButton.Right))
                    {
                        if (RightClicked != null)
                        {
                            RightClicked.Invoke(this, EventArgs.Empty);
                        }
                    }
                }
            }

            var childrenToUpdate = new Stack <Control>(Children);

            while (childrenToUpdate.Count > 0)
            {
                Control child = childrenToUpdate.Pop();

                if (!child.Hidden)
                {
                    child.UpdateInput(input);
                }
            }
        }
Beispiel #2
0
 private void OnMiddleClicked()
 {
     MiddleClicked?.Invoke(this, new ClickEventArgs(Mouse.Button.Middle));
 }