From 4794f672d61ea0186432d73d173c92e187dbdf04 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 15 Dec 2015 13:19:16 +0200 Subject: Prevent text selection on iOS devices with long tap (#19367) Text or elements should not get selected when there's a context click listener. Pre-emptively prevent text selection for the whole widget when that happens. Change-Id: I3c09d8b2c25d383d6abe079f0fee3809cf5838c7 --- client/src/com/vaadin/client/ui/AbstractComponentConnector.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index f1ed0caf10..9a1c21d556 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -190,6 +190,10 @@ public abstract class AbstractComponentConnector extends AbstractConnector final MouseEventDetails mouseEventDetails = MouseEventDetailsBuilder.buildMouseEventDetails( event.getNativeEvent(), getWidget().getElement()); + // Prevent selection for the element while pending long tap. + WidgetUtil.setTextSelectionEnabled(getWidget().getElement(), + false); + final EventTarget eventTarget = event.getNativeEvent() .getEventTarget(); @@ -285,6 +289,8 @@ public abstract class AbstractComponentConnector extends AbstractConnector */ private void cancelTouchTimer() { if (longTouchTimer != null) { + // Re-enable text selection + WidgetUtil.setTextSelectionEnabled(getWidget().getElement(), true); longTouchTimer.cancel(); } } -- cgit v1.2.3