summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-12-11 14:39:56 +0200
committerVaadin Code Review <review@vaadin.com>2015-12-15 09:32:31 +0000
commit05356b0cb628e7f7604991adf82387c746870104 (patch)
treed34b4d95e6ffda571b8808f38e64863ab40ec671 /client
parentdace5ab66322c226b2cce79848a9c0518740f020 (diff)
downloadvaadin-framework-05356b0cb628e7f7604991adf82387c746870104.tar.gz
vaadin-framework-05356b0cb628e7f7604991adf82387c746870104.zip
Add a method to clear selected text on context click (#19367)
Change-Id: Id7ec7013bcff446cdf3ce0f2088cb20b0708a56b
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/WidgetUtil.java12
-rw-r--r--client/src/com/vaadin/client/connectors/GridConnector.java3
-rw-r--r--client/src/com/vaadin/client/ui/AbstractComponentConnector.java4
-rw-r--r--client/src/com/vaadin/client/ui/table/TableConnector.java7
-rw-r--r--client/src/com/vaadin/client/ui/tree/TreeConnector.java2
5 files changed, 25 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/WidgetUtil.java b/client/src/com/vaadin/client/WidgetUtil.java
index 631d28c26c..8161ceff19 100644
--- a/client/src/com/vaadin/client/WidgetUtil.java
+++ b/client/src/com/vaadin/client/WidgetUtil.java
@@ -1333,6 +1333,18 @@ public class WidgetUtil {
}-*/;
/**
+ * JavaScript hack to clear text selection in various browsers.
+ *
+ * @since 7.6
+ */
+ public native static void clearTextSelection()
+ /*-{
+ if ($wnd.getSelection) {
+ $wnd.getSelection().removeAllRanges();
+ }
+ }-*/;
+
+ /**
* The allowed value inaccuracy when comparing two double-typed pixel
* values.
* <p>
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java
index 336469139c..0b485a8e5a 100644
--- a/client/src/com/vaadin/client/connectors/GridConnector.java
+++ b/client/src/com/vaadin/client/connectors/GridConnector.java
@@ -43,6 +43,7 @@ import com.vaadin.client.DeferredWorker;
import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.client.ServerConnector;
import com.vaadin.client.TooltipInfo;
+import com.vaadin.client.WidgetUtil;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.client.connectors.RpcDataSourceConnector.DetailsListener;
@@ -1197,6 +1198,8 @@ public class GridConnector extends AbstractHasComponentsConnector implements
getRpcProxy(GridServerRpc.class).contextClick(eventCell.getRowIndex(),
rowKey, columnId, section, details);
+
+ WidgetUtil.clearTextSelection();
}
/**
diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
index 1b3f5de3b1..f1ed0caf10 100644
--- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
+++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
@@ -45,6 +45,7 @@ import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL;
import com.vaadin.client.Util;
import com.vaadin.client.VConsole;
+import com.vaadin.client.WidgetUtil;
import com.vaadin.client.annotations.OnStateChange;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.metadata.NoDataException;
@@ -132,7 +133,6 @@ public abstract class AbstractComponentConnector extends AbstractConnector
// remove the touch handlers as well
unregisterTouchHandlers();
-
}
}
@@ -324,6 +324,8 @@ public abstract class AbstractComponentConnector extends AbstractConnector
// The default context click implementation only provides the mouse
// coordinates relative to root element of widget.
getRpcProxy(ContextClickRpc.class).contextClick(details);
+
+ WidgetUtil.clearTextSelection();
}
/**
diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java
index 7e7995b5e1..cdd9397976 100644
--- a/client/src/com/vaadin/client/ui/table/TableConnector.java
+++ b/client/src/com/vaadin/client/ui/table/TableConnector.java
@@ -28,11 +28,11 @@ import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
-import com.vaadin.client.HasChildMeasurementHintConnector;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler;
import com.vaadin.client.DirectionalManagedLayout;
+import com.vaadin.client.HasChildMeasurementHintConnector;
import com.vaadin.client.HasComponentsConnector;
import com.vaadin.client.Paintable;
import com.vaadin.client.ServerConnector;
@@ -56,7 +56,8 @@ import com.vaadin.shared.ui.table.TableState;
@Connect(com.vaadin.ui.Table.class)
public class TableConnector extends AbstractFieldConnector implements
HasComponentsConnector, ConnectorHierarchyChangeHandler, Paintable,
- DirectionalManagedLayout, PostLayoutListener, HasChildMeasurementHintConnector {
+ DirectionalManagedLayout, PostLayoutListener,
+ HasChildMeasurementHintConnector {
private List<ComponentConnector> childComponents;
@@ -120,6 +121,8 @@ public class TableConnector extends AbstractFieldConnector implements
getRpcProxy(TableServerRpc.class).contextClick(rowKey, colKey, section,
details);
+
+ WidgetUtil.clearTextSelection();
}
protected VScrollTableRow getScrollTableRow(Element e) {
diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
index 6fec6b9f38..f49f44e802 100644
--- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java
+++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
@@ -394,5 +394,7 @@ public class TreeConnector extends AbstractComponentConnector implements
}
getRpcProxy(TreeServerRpc.class).contextClick(key, details);
+
+ WidgetUtil.clearTextSelection();
}
}