is there any way to access the selection state of a button?

The IsPressed() method is what I want but it is protected and obsolete. I want to send a message while a button is pressed, not on OnClick. The ways I see are

a) to duplicate internal button code and maintain a duplicate state. I do not like this solution as it fragile and error prone as the exact specification for button states is not available and it may change.

b) writing a new button component from scratch :frowning:

edit: to duplicate the button state I will need to implement at least IPointerDownHandler, IPointerUpHandler, IPointerExitHandler, IPointerEnterHandler, ISelectHandler, IDeselectHandler and keep one or more internal states in addition to the visible button state. Yes this is doable but fragile and error prone since there is documented button state, state diagram. I am looking for something simpler and more robust than this.

You can try using the OnPointerDown method.

I rechecked and found that there are two IsPressed() methods and only 1 is obsolete. so it can be accessed by subclassing Button. so this will allow accessing isPressed().
public class ButtonExtras : Button {

    public bool PubIsPressed(){
        return IsPressed();