Exemple #1
0
    public override void _Input(InputEvent e)
    {
        if (e is InputEventMouseButton iemb)
        {
            Vector2 pos = ToLocal(iemb.GetPosition());
            if (InputUtil.IsLeftPress(iemb) && rect.HasPoint(pos))
            {
                OnLeftPress();
            }
        }

        if (e is InputEventMouseMotion iemm)
        {
            Vector2 pos = ToLocal(iemm.GetPosition());
            if (rect.HasPoint(pos))
            {
                hovered = true;
                OnHover();
            }
            else
            {
                if (hovered)
                {
                    hovered = false;
                    OnHoverOff();
                }
            }
        }
    }