Button trigger not fired on touch enabled devices using google chrome and mouse click
Closed this issue · 3 comments
Trigger event gets not fired in Chrome using OpenLayers.Control.Button on touch enabled devices on mouse click - but works on touch.
No Problems in current FireFox, Internet Explorer and Microsoft Edge
Can be verified in the Openlayers two default samples (you need a touch enabled device ;)
- http://dev.openlayers.org/examples/text-button-panel.html#zoomIn - Alerts should be shown on buttons click
- http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/mobile-navigation.html - Zoom in/out should be excuted on buttons click
Got it. The reason is the change done by @pgiraud:
**Don't listen to mouse events if the device is touch capable:**9a4f5d1
I don't know why someone would disable buttonClick Events just because the screen is touch enabled. Unfortunatelly @pgiraud didnt leave a description or a reason for the changes he did.
Nowadays many notebooks come with touchscreens but the users still take the mouse or even use both devices.
I revert the changes and now both works just perfect.
And the reason why it occurs only in chrome was that the new added "isDeviceTouchCapable" property didn't work properly. Only Chrome responds true.
Hope this helps others in the same trap.
Yes, it is possible that on some older Android devices the #1216 issue occurs. But since more and more mixed devices (Mouse/Touch) are in use, I think the possibility that the buttons are locked due to this commit is very high.
The condition @pgiraud added prevents buttonClick on all mixed devices!
if (element && (OpenLayers.Event.isLeftClick(evt) && !this.isDeviceTouchCapable ||!~evt.type.indexOf("mouse")))
I already tested the reverted version on following devices:
- HTC ONE, Android 5.0.2
- LG G4, Android 6.0
- IPAD AIR
- Lenovo YOGA 700-14ISK Notebook, Windows 10, (Touchscreen)
- ASUS G501JW, Windows 10, (NO Touchscreen)
Browser: Chrome, Firefox, IE, Edge
ButtonClick and/or Touch works on all this devices and did not raise a second click.
But if the issue still occurs on some older Android devices, we need an other solution instead of preventing any ButtonClick.