Using ClickDetector's MouseHoverEnter with touch devices


#1

Hello all,
I have a dragging mechanic in my game that fires an action whenever the mouse goes over a clickdetector. This works just fine when using a mouse, but when testing or emulating with any touch-based device (e.g. iPad, iPhone) the ClickDetector’s .MouseHoverEnter event doesn’t fire while dragging.

I looked through documentation and didn’t find any similar events but for touch input. What can I do for a workaround?


#2

You may want to try Mouse.Target as an alternative.
Although I’m unsure if this would solve the issue.


#3

The UserInputService sports most events that you’ll need in terms of utilising player input, without using methods exposed by button objects. If you have a look around, you’ll notice various functions you can seek out and if they may help you. In terms of using one of the input functions (InputBegan/Changed/Ended), InputObjects contain information about the input that was passed.


#4

Hmm, I guess that could work with a loop while the dragging is active.

Oh well, I was hoping for something better than this workaround. Thanks though!


#5

You could use Mouse.Move:Connect()
I personally think it’s better than while loops to prevent unnecessary checks.


#6

I use RunService:BindToRenderStep() and RunService:UnbindToRenderStep() to keep the code responsive and avoid unnecessary checks when the dragging isn’t active :grin: