We’re developing custom widgets for a mobile game and ran into issues where we need to detect when the user dragged outside of the widget bounds, but noticed there was no touch function or event for it. There is “On Mouse Leave” which we originally assumed wouldn’t work on mobile but after some investigation and testing we found it worked completely fine.
We are not blocked by this issue or slowed down by it (anymore). Our ask is that a future version of Unreal adds a semantically correct event so it’s immediately clear to the developer that the event is available, what platform it is intended for (primarily mobile, but anything with a “touch” interface) and that it is expected to work.
Also: I noticed there is a function for “On Mouse Button Double Click” which could have a similar/matching “On Touch Double Tap” function but none existed. I tried using the mouse function on device, but it wasn’t being called. I haven’t done any investigation into why. We did build some basic double tap functionality ourselves using some delta tracking between On Touch Started calls, but if the “Double Tap” function existed maybe we wouldn’t have needed to.
Steps to Reproduce
* Create a new assets deriving from User Widget
* Notice there is an event “On Mouse Leave” but no “On Touch Leave” event
* Also notice there is a function “On Mouse Button Double Click” but no similar/matching “On Touch Double Tap” function
Hi,
Agreed that the terminology here can be a bit confusing/inconsistent, largely as a consequence of the engine being built initially with mouse input in mind (along with the difficulty in deprecating/renaming things that are overridden extensively in projects). To give a bit of background:
- Most Slate events correspond directly to platform-level messages (i.e. MouseDown, KeyDown, MouseMove, etc.) This includes OnMouseDoubleClick, as this event is explicitly sent by all three desktop platforms (PC, Mac, Linux) and doesn’t require any detection on our side. An advantage of this approach is that OS-level settings for the timing will apply since the detection is happening on the platform. This is also why you don’t see it on touch devices; no touchscreen devices (as far as I know) have native double-tap events like this.
- Enter/Leave events (like OnMouseLeave) are a bit of a weird case, as we do have to process those at the engine level. They can even originate from a few different places.. MouseMove events, TouchMove events, or even from within the engine instead of externally (if the widget under the cursor moves out from under it, or if a specific widget is captured and we need to flush input on the current hovered widget)
- Things are further complicated with desktop touchscreen devices becoming more common (i.e. a Windows laptop with a touch screen, or a handheld like the Steam Deck). These devices tend to send both a native touch event and a simulated mouse event, so that applications not handling touch explicitly will still work somewhat well. As a result, you can detect both of these independently within the engine, and there are some cvars to filter simulated mouse events since they often cause double inputs when routing both mouse and touch to the same action (Slate.PreventDuplicateMouseEventsForTouchForWindows7, with a Linux version coming in 5.8)
- Finally, we have some rudimentary gesture detection in the engine, in two forms. Native gesture events from the platform should route through OnTouchGesture, though as far as I know those are only really implemented for Mac (so that touchpad gestures can control the editor, though you could also handle them in an application). Additionally, there’s an FGestureDetector class which provides a barebones implementation for detecting gestures at the engine level, which it does by siphoning events from the Slate User and feeding Gesture events back into OnTouchGesture. It only supports long press by default, but is built to make it easy to add your own gestures.
All of that is to say, I hope we can clean the terminology up a bit here but we’re always having to react to the devices and APIs that exist on the market today, so things have become a bit convoluted as a result. I’ll pass this feedback along to the UI team, as I think the MouseEnter/MouseLeave events are particularly ambiguous (since they respond to both mouse and touch out-of-the-box).
Best,
Cody
Hi,
Similar situation here, we should probably rename the event “CaptureInput” (or similar) since it’s going to cause any “pointer” input to route to the capturing widget. I’ll pass this feedback along as well.
Best,
Cody
Thank you for the detailed answer 
A very related thing that I’ve been investigating today is this function
FReply::Handled().CaptureMouse(…)
I want to be able to tap on a widget and still get input events even when I drag beyond the bounds (Like the VirtualJoystick does) and I had to look at the code and test to confirm that the event does work on mobile (it did!). If there was a touch version, or named not specifically “mouse” it would’ve been more immediately obvious that it should work.