diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-12-15 13:39:12 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-12-15 13:01:46 +0000 |
commit | 899f45bb45d61b9c1738dbdf9a530aa6a2c9ee12 (patch) | |
tree | 04b208e6c34bc930977c715f7b57a510982402b2 | |
parent | 1423f6e15b3a68fd998bb22626982e214c504be5 (diff) | |
download | vaadin-framework-899f45bb45d61b9c1738dbdf9a530aa6a2c9ee12.tar.gz vaadin-framework-899f45bb45d61b9c1738dbdf9a530aa6a2c9ee12.zip |
Fix text selection and context click events for Android devices (#19367)
Text and element selection needs to be disabled on touch start for
Android as well. Other touch event handling used by iOS devices is not
used on Android.
Change-Id: I7f17af437ddf4f7b747232fbd19b2cd5c825c0e2
-rw-r--r-- | client/src/com/vaadin/client/ui/AbstractComponentConnector.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index 9a1c21d556..c312cf5325 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -181,6 +181,15 @@ public abstract class AbstractComponentConnector extends AbstractConnector return; } + // Prevent selection for the element while pending long tap. + WidgetUtil.setTextSelectionEnabled(getWidget().getElement(), + false); + + if (BrowserInfo.get().isAndroid()) { + // Android fires ContextMenu events automatically. + return; + } + /* * we need to build mouseEventDetails eagerly - the event won't * be guaranteed to be around when the timer executes. At least @@ -190,10 +199,6 @@ 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(); @@ -278,8 +283,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector } protected boolean shouldHandleLongTap() { - final BrowserInfo browserInfo = BrowserInfo.get(); - return browserInfo.isTouchDevice() && !browserInfo.isAndroid(); + return BrowserInfo.get().isTouchDevice(); } /** @@ -288,9 +292,9 @@ public abstract class AbstractComponentConnector extends AbstractConnector * @since 7.6 */ private void cancelTouchTimer() { + WidgetUtil.setTextSelectionEnabled(getWidget().getElement(), true); if (longTouchTimer != null) { // Re-enable text selection - WidgetUtil.setTextSelectionEnabled(getWidget().getElement(), true); longTouchTimer.cancel(); } } |