Exemplo n.º 1
0
        private void OnMouseInputEvent(Vector2 pixelPosition, MouseButton button, InputEventType type, float value = 0)
        {
            // The mouse wheel event are still received even when the mouse cursor is out of the Window boundaries. Discard the event in this case.
            if (type == InputEventType.Wheel && !UiControl.ClientRectangle.Contains(UiControl.RelativeCursorPosition))
            {
                return;
            }

            // the mouse events series has been interrupted because out of the window.
            if (type == InputEventType.Up && !MouseButtonCurrentlyDown[(int)button])
            {
                return;
            }

            CurrentMousePosition = NormalizeScreenPosition(pixelPosition);

            var mouseInputEvent = new MouseInputEvent {
                Type = type, MouseButton = button, Value = value
            };

            lock (MouseInputEvents)
                MouseInputEvents.Add(mouseInputEvent);

            if (type != InputEventType.Wheel)
            {
                var buttonId = (int)button;
                MouseButtonCurrentlyDown[buttonId] = type == InputEventType.Down;
                HandlePointerEvents(buttonId, CurrentMousePosition, InputEventTypeToPointerState(type), PointerType.Mouse);
            }
        }
Exemplo n.º 2
0
 protected override void SetMousePosition(Vector2 normalizedPosition)
 {
     Cursor.Position = new Point(
         (int)(UiControl.ClientRectangle.Width * normalizedPosition.X),
         (int)(UiControl.ClientRectangle.Height * normalizedPosition.Y));
 }