using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using UnityEngine.EventSystems;

public class SliderCallbackExtension : MonoBehaviour, IPointerClickHandler, IPointerUpHandler
{
    private Slider _slider;
    public UnityEvent RightClickAction = new UnityEvent();
    public UnityEvent<float> PointerUpAction = new UnityEvent<float>();
    public UnityEvent<float> ValueChangedAction = new UnityEvent<float>();

    private void Awake()
    {
        _slider = GetComponent<Slider>();
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Right)
        {
            RightClickAction?.Invoke();
        }
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Left)
        {
            PointerUpAction?.Invoke(_slider.value);
        }
    }

    public void OnValueChanged(float value)
    {
        ValueChangedAction.Invoke(value);
    }
}