Ejemplo n.º 1
0
        /// <summary>
        ///		Method that injects a mouse movement event into the system.
        /// </summary>
        /// <param name="deltaX">Amount the mouse moved on the x axis.</param>
        /// <param name="deltaY">Amount the mouse moved on the y axis.</param>
        /// <returns>Returns true if the event was Handled, and false if it is not.</returns>
        public void InjectMouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            GUIMouseEventArgs guiMouseEvent = new GUIMouseEventArgs(e.Button, e.Clicks, ClientToScreen(new Vector2(e.X, e.Y)), e.Delta);

            MouseCursor mouse = MouseCursor.Instance;

            // move the mouse cursor
            mouse.Position = guiMouseEvent.Position;

            Window destWindow = GetTargetWindow(guiMouseEvent.Position);

            // if there is no GUI sheet, then there is nowhere to send input
            // TODO: keep an eye on passing the same args around
            if (destWindow != null)
            {
                if (destWindow != windowWithMouse)
                {
                    if (windowWithMouse != null)
                    {
                        windowWithMouse.OnMouseLeaves(guiMouseEvent);
                    }

                    windowWithMouse = destWindow;
                    destWindow.OnMouseEnters(guiMouseEvent);
                }

                while (destWindow != null &&
                       !destWindow.OnMouseMove(guiMouseEvent))
                {
                    destWindow = destWindow.Parent;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///		Method that injects a mouse wheel scroll event into the system.
        /// </summary>
        /// <param name="delta">Amount that the mouse wheel was moved.</param>
        /// <returns>Returns true if the event was Handled, and false if it is not.</returns>
        public void InjectMouseWheel(System.Windows.Forms.MouseEventArgs e)
        {
            Vector2 screenPos  = ClientToScreen(new Vector2(e.X, e.Y));
            Window  destWindow = GetTargetWindow(screenPos);

            if (destWindow != null)
            {
                GUIMouseEventArgs guiMouseEvent = new GUIMouseEventArgs(e.Button, e.Clicks, screenPos, e.Delta);
                destWindow.OnMouseWheel(guiMouseEvent);
            }
        }
Ejemplo n.º 3
0
        public void InjectMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            GUIMouseEventArgs guiMouseEvent = new GUIMouseEventArgs(e.Button, e.Clicks, ClientToScreen(new Vector2(e.X, e.Y)), e.Delta);
            Window            destWindow    = GetTargetWindow(guiMouseEvent.Position);
            Window            eventWindow   = destWindow;

            while (eventWindow != null &&
                   !eventWindow.OnMouseButtonDown(guiMouseEvent))
            {
                eventWindow = eventWindow.Parent;
            }
        }