GuiButton Activated Event & 'Mouse' Events

All the time I’ve been working with gui’s I’ve relied on the ‘mouse’ events (MouseButton1Click, MouseButton1Down, etc) to handle input. But given the names of them, I’ve decided to look into alternatives since having ‘mouse’ in their name doesn’t feel too comforting for a game I want to be played on multiple platforms, which lead me to the Activated event.

At first thought, it seemed to be what I was looking for, since it passes an InputObject. However, I can’t seem to get it to do anything. I have a local script as a child of a text button with this code:

script.Parent.Activated:Connect(function(Input)
	print("--Button--")
	print("Delta:", Input.Delta)
	print("KeyCode:", Input.KeyCode)
	print("Position:", Input.Position)
	print("UserInputState:", Input.UserInputState)
	print("UserInputType:", Input.UserInputType)
end)

What is this event for and how does it work? And is it fine to rely on the ‘mouse’ events? My instincts say no, but I can’t find a proper alternative that respects all platforms.

2 Likes

For now you should be fine using MouseButton1Click and etc since it will work on all formfactors (despite the misleading name)

Youre correct to assume Activated is a much better (and comfier name) for these events and passing through the InputObject is a nice touch. However the event is not activated (ha) yet and won’t work.

I’m not at all aware of when it’ll be ready but it’ll be nice when it is.

4 Likes

Thanks for the quick response. Can’t wait for it to be activated.

5 Likes

This seems to be activated now, but it only fires when UserInputState is Ended. I’m sure this will change, I hope.