Description:
I'm developing a custom drag system in UMG for a VR/UI project in Unreal Engine 5.4.4. It works perfectly with mouse input, but I'm having issues when using touch input on a mobile device or touchscreen.
How My System Works (Mouse - Fully Functional) I have a main UI widget (WBP_GaleriaGeral) containing a ScrollBox with dynamically generated buttons (WBP_GaleriaIcon).
When I press a button inside the ScrollBox, a new image widget (WBP_ImageDrag) is created at the mouse position and added to the viewport.
Inside WBP_ImageDrag, there is a Tick event that updates the widget’s position to follow the mouse as long as a boolean (AllowDrag) is true.
AllowDrag is set to true in Construct and on Mouse Button Down, and set to false on Mouse Button Up.
Problem with Touch Input When I touch a button (WBP_GaleriaIcon) to create the image widget (WBP_ImageDrag), the first touch always uses the last known mouse position, not the actual touch position.
This means the first spawned WBP_ImageDrag appears in the wrong place, often far from the touch location.
I tried overriding On Touch Started and On Touch Ended to manually set AllowDrag = true/false, just like I do with the mouse, but the issue remains.
After the first touch, dragging works correctly, meaning that Unreal isn't recognizing the new touch input as a position update immediately.
What I Tried (Without Success) Manually setting the mouse position to the touch position right before creating WBP_ImageDrag.
Forcing a "mouse move" event when touch starts.
Using "Convert Screen Location to World Space" to update the position before spawning WBP_ImageDrag.
Calling "Set Input Mode Game and UI" when touch starts.
Checking "Use Mouse for Touch" in Project Settings → Input.
What I Need Help With How can I ensure that the first touch correctly updates the mouse position before spawning the widget?
Is there a way to force Unreal to recognize the touch location immediately upon pressing?
Am I missing a step to properly synchronize touch input and mouse position in UMG?
Thanks in advance for any help!