OnSelect - from mouse or keyboard/controller?

I am using ISelectHandler and IPointerClickHandler. Now when a UI Object is clicked, it is also automatically selected first. I want to find out if that selection was triggered by a pointer click, or by a keyboard/controller event.

Since OnSelect only has access to the BaseEventData I have no idea how to do this. My first idea was to use the input module involved, but since I’m using the Standalone module, both mouseclick and keyboard/controller event come from the same module, so I can’t use that to differentiate.

Any ideas?

Still nothing? I feel like this is a pretty big issue - there’s a lot of different things that can trigger OnSelect but it’s impossible to find out what caused it from within OnSelect.

I know this is old but since it is the first result on Google and I just ran into this issue…

One way to check if OnSelect is caused by the mouse is as follows:

public override void OnSelect(BaseEventData eventData)
{
    if (eventData is PointerEventData)
    {
        Debug.Log("Do Mouse stuff here");
    }
    else
    {
        Debug.Log("Do other stuff here");
    }
}
5 Likes