Пример #1
0
        private void OnMouseMoveEvent(SDL.SDL_MouseMotionEvent e)
        {
            var previousMousePosition = CurrentMousePosition;

            CurrentMousePosition = NormalizeScreenPosition(new Vector2(e.x, e.y));
            // Discard this event if it has been triggered by the replacing the cursor to its capture initial position
            if (IsMousePositionLocked && Cursor.Position == _capturedPosition)
            {
                return;
            }

            CurrentMouseDelta += CurrentMousePosition - previousMousePosition;

            // trigger touch move events
            foreach (MouseButton button in Enum.GetValues(typeof(MouseButton)))
            {
                var buttonId = (int)button;
                if (MouseButtonCurrentlyDown[buttonId])
                {
                    HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Move, PointerType.Mouse);
                }
            }

            if (IsMousePositionLocked)
            {
                Cursor.Position = _capturedPosition;
            }
        }
Пример #2
0
        private void OnMouseMoveEvent(SDL.SDL_MouseMotionEvent e)
        {
            var previousMousePosition = CurrentMousePosition;

            CurrentMousePosition = NormalizeScreenPosition(new Vector2(e.x, e.y));
            // Discard this event if it has been triggered by the replacing the cursor to its capture initial position
            if (IsMousePositionLocked && (e.x == _relativeCapturedPosition.X && e.y == _relativeCapturedPosition.Y))
            {
                return;
            }

            CurrentMouseDelta += CurrentMousePosition - previousMousePosition;

            // trigger touch move events
            foreach (MouseButton button in Enum.GetValues(typeof(MouseButton)))
            {
                var buttonId = (int)button;
                if (MouseButtonCurrentlyDown[buttonId])
                {
                    HandlePointerEvents(buttonId, CurrentMousePosition, PointerState.Move, PointerType.Mouse);
                }
            }

            if (IsMousePositionLocked)
            {
                // Restore position to prevent mouse from going out of the window where we would not get
                // mouse move event.
                UiControl.RelativeCursorPosition = _relativeCapturedPosition;
            }
        }
Пример #3
0
        public static void HandleEvent(SDL.SDL_Event inputEvent)
        {
            _mouseMotionEvent    = new SDL.SDL_MouseMotionEvent();
            _mouseWheelDirection = 0;

            switch (inputEvent.type)
            {
            case SDL.SDL_EventType.SDL_KEYDOWN:
                _keysDown.Add(inputEvent.key.keysym.sym);
                break;

            case SDL.SDL_EventType.SDL_KEYUP:
                RemoveKey(inputEvent.key.keysym.sym);
                break;

            case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN:
                _mouseButtonsDown.Add(inputEvent.button.button);
                break;

            case SDL.SDL_EventType.SDL_MOUSEBUTTONUP:
                RemoveMouseButton(inputEvent.button.button);
                break;

            case SDL.SDL_EventType.SDL_MOUSEMOTION:
                _mouseMotionEvent = inputEvent.motion;
                break;

            case SDL.SDL_EventType.SDL_MOUSEWHEEL:
                _mouseWheelDirection = (int)inputEvent.wheel.direction;
                break;
            }
        }
Пример #4
0
 private void OnMouseMoveEvent(SDL.SDL_MouseMotionEvent e)
 {
     if (IsPositionLocked)
     {
         MouseState.HandleMouseDelta(new Vector2(e.xrel, e.yrel));
     }
     else
     {
         MouseState.HandleMove(new Vector2(e.x, e.y));
     }
 }
Пример #5
0
        private void OnMouseMoveEvent(SDL.SDL_MouseMotionEvent e)
        {
            if (IsPositionLocked)
            {
                MouseState.HandleMouseDelta(new Vector2(e.x - relativeCapturedPosition.X, e.y - relativeCapturedPosition.Y));

                // Restore position to prevent mouse from going out of the window where we would not get
                // mouse move event.
                uiControl.RelativeCursorPosition = relativeCapturedPosition;
            }
            else
            {
                MouseState.HandleMove(new Vector2(e.x, e.y));
            }
        }
Пример #6
0
 /// <summary>
 /// Handle mouse move to handle hover cursor and text selection.
 /// </summary>
 /// <param name="parent">the control hosting the html to set cursor and invalidate</param>
 /// <param name="e">the mouse event args</param>
 public void HandleMouseMove(SDL.SDL_MouseMotionEvent e)
 {
     _htmlContainerInt.HandleMouseMove(new ControlAdapter(SDL2Adapter.Instance, e.ToRPoint()), e.ToRPoint());
 }
Пример #7
0
 public void ProcessMouseEvent(SDL.SDL_MouseMotionEvent motion)
 {
     state.X += motion.xrel;
     state.Y += motion.yrel;
 }
Пример #8
0
 public static RPoint ToRPoint(this SDL.SDL_MouseMotionEvent e)
 {
     return(new RPoint(e.x, e.y));
 }
Пример #9
0
 public MouseMotionEventArgs(SDL.SDL_MouseMotionEvent evt)
 {
     _evt = evt;
 }