Ejemplo n.º 1
0
        protected override void Input(InputEvent ev)
        {
            if (ev is InputEventMouse)
            {
                var mouseEvent = ev as InputEventMouse;
                if (mouseEvent.Pressed)
                {
                    if (!isPressed)
                    {
                        var locationRect = new Vector2(ShapeRect.Position.X * GlobalScale, ShapeRect.Position.Y * GlobalScale);
                        locationRect += GlobalPosition;
                        var localRect = new RectangleF(locationRect.X, locationRect.Y, ShapeRect.Width * GlobalScale, ShapeRect.Height * GlobalScale);

                        if (localRect.Contains(mouseEvent.Position))
                        {
                            isPressed = true;
                            EventPressed?.Invoke();
                        }
                    }
                }
                else
                {
                    if (isPressed)
                    {
                        isPressed = false;
                        EventReleased?.Invoke();
                    }
                }
            }
            base.Input(ev);
        }
Ejemplo n.º 2
0
 private void OnReleased()
 {
     Debug.WriteLine("Press PLAY");
     EventPressed?.Invoke();
     Processing  = false;
     InputEnable = false;
 }