How to right-click a button on unity

Ok, so basically a button only detects left-click right? Well, is there a way to make it detect right click and execute code? Here is my script so far:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ButtonManager : MonoBehaviour {

    public bool aimTrigger = false;
    public GameObject gun;

    public void AIM()
    {
        if (aimTrigger)
        {
            gun.GetComponent<AimScript>().Aim = false;
            aimTrigger = false;
        }
        else
        {
            if (!aimTrigger)
            {
                gun.GetComponent<AimScript>().Aim = true;
                aimTrigger = true;
            }
        }
    }

}

it calls the method AIM when the button is pressed, execpt the button can only be left clicked, not right-clicked. Is there a way around this? sorry for not explaining good

This has been asked and answered before here, with same solution posted twice on the forum:

https://forum.unity.com/threads/can-the-ui-buttons-detect-a-right-mouse-click.279027/

https://forum.unity.com/threads/ui-button-detecting-right-mouse-button.336111/