Fix UI Element input events on multiple touches. #4562
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4341 and #4470
Issue #4341 root cause is that the
element-drag-helper
class (used byScrollview
components and similar) uses Window DOM Events for handling dragging, and does not check the actual target of the event. This leads to any touch interaction being handled by all UI Elements at once. Issue #4470 is also related to multitouch.This PR makes the
element-drag-helper
use the Events triggered byelement-input
system (rather than Window DOM events) for handling dragging. Theelement-input
system already contains all logic and checks necessary to figure out which is the correct element a given user events (like touch or mouse) should target.The only reason
element-drag-helper
was still using Window DOM events was to handle the cases of outside-of-canvas events (like letting go of mouse or touch outside the bounds of the screen), whereaselement-input
system was not. This PR also addresses that by havingelement-input
handle that use-case properly, by removing hard-coded checks that prevent such events from firing. Note thatelement-input
system does also Window DOM events.Finally, this PR also makes the
mouse
events also useelement-input
system so everything is standardised to use the same system.Testing
Test project with custom engine build: https://launch.playcanvas.com/1223792
Before
Before, any touch event (to any target) was being processed by all
element-drag-helper
s, so there were flickering and unwanted movement of bars. Also, if there was any touch still active, you couldn't click the button. It would highlight, but not increase its value on click.RPReplay_Final1660816738.MP4
After
After, each touch finger is handled properly by its target element only, and you can click on the button.
RPReplay_Final1660817255.MP4
I confirm I have read the contributing guidelines and signed the Contributor License Agreement.