-
-
Notifications
You must be signed in to change notification settings - Fork 729
Can not get proper touch event data in backend #4577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Works fine on Samsung Internet on Android, Safari on iOS. Definitely not a NiceGUI issue, otherwise all 3 successful cases we've seen so far would be broken. You really need to check your browser, and note that "The touchmove event only works on touch screens" There may be tricky cases such as a touchscreen which simply drags a mouse across (occurs with some cheap Windows tablets on AliExpress, big interactive displays, or when over a Remote Desktop connection with a client which cannot send touch input. I have had the displeasure to encounter all 3 scenarios at least once) |
Look at the event['touches']['0'] its an empty dict in the event printed in the terminal... likewise all the key storing touch position are empty dict, it should contain 'clientX' and 'clientY' |
Ah, so that's the core issue here. Thank you for pointing out that. 😅 But at least, we know the event handler "touchmove" is being triggered. Investigation follows. |
Got a fix in #4579 But not sure if there are other tricky objects like But it won't make itself to release quickly, so js_handler is your best friend for now. |
Note that the test code Minimum reproduction: ui.card().classes('w-80 h-80').on('touchmove', lambda e: print(e.args['touches']['0'])) |
Note that we can reproduce the problem with developer tools like this: https://stackoverflow.com/a/36877125/3419103 I wonder why there isn't any JavaScript error when serializing the |
When #4579 patches the serialization by introducing advance_serialize which is known-good for |
Ok, I finally understand. With some debug code in const touch = filtered.touches[0];
const json = JSON.stringify(touch, (k, v) => (v instanceof Node || v instanceof Window ? undefined : v));
console.log(touch, json); They look like regular objects with regular properties. But apparently the properties are "non-enumerable". Cursor explains it like this:
I'm still not very happy with a special treatment for Touch objects. But it looks like we have no other choice. |
I believe, though we may not be exactly 100% happy, we can't be more happier than the current solution which handles If we implement a custom Now, we know, the serializer:
Predictable and simple. What more can you ask for. |
First Check
Example Code
Description
start the app. open the app in a browser of a touch screen device that is connected to the same network. move your finger across the touch area, no touch position is shown.
NiceGUI Version
2.13.0
Python Version
3.12
Browser
Chrome
Operating System
Android
Additional Context
No response
The text was updated successfully, but these errors were encountered: