When finger leaves mobile button while still holding down, userinput.end isnt fired

Here is a demo I made showing how it is supposed to work. When I hold down the button, the block is green. When I let go, the block turns back to red.

But when I have my finger/mouse leave the button while still holding down, upon release it does not fire the end of the input. It remains green because it still believes that I’m holding it.

I have tried searching on the DevFourm for the same problem, but I was unable to find any. I also know that I could make the buttons custom, but I would prefer to use contextactionservice if I can.

7 Likes

12/19/21 EDIT: Enum.InputState.Cancel happens when the player slides their finger off the Context Action Button and then lets go of the screen. Enum.InputState.End only happens if the player keeps their finger on the button and then lets go of the screen. You will need to use both Enum.InputState.End and Enum.InputState.Cancel to get the result you want.

8 Likes

I can’t quite figure out what event returns this Enum.InputState for an ImageButton. Which event would I use?

If you’re using ContextActionService:BindAction(), it just magically gets passed as an argument.

If you are just using an ImageButton, you can use the .Activated event. There’s two Parameters for that Event. The one that’ll be helpful is the InputObject parameter. InputObject is an Instance that can not exist in the Explorer, much like a RaycastResult. But like any normal Instance, it still has properties, and one of those properties is UserInputState, which is the thing you are asking for.

2 Likes