summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/WidgetUtil.java23
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java9
2 files changed, 32 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/WidgetUtil.java b/client/src/com/vaadin/client/WidgetUtil.java
index e9ec163612..b0e0030769 100644
--- a/client/src/com/vaadin/client/WidgetUtil.java
+++ b/client/src/com/vaadin/client/WidgetUtil.java
@@ -1307,6 +1307,29 @@ public class WidgetUtil {
}-*/;
/**
+ * JavaScript hack to prevent text selection in various browsers.
+ *
+ * @since
+ * @param e
+ * element for enabling or disabling text selection
+ * @param enable
+ * <code>true</code> if selection is enabled; </code>false</code>
+ * if not
+ */
+ public native static void setTextSelectionEnabled(Element e, boolean enable)
+ /*-{
+ if (!enable) {
+ e.ondrag = function () { return false; };
+ e.onselectstart = function () { return false; };
+ e.style.webkitUserSelect = "none";
+ } else {
+ e.ondrag = null;
+ e.onselectstart = null;
+ e.style.webkitUserSelect = "text";
+ }
+ }-*/;
+
+ /**
* The allowed value inaccuracy when comparing two double-typed pixel
* values.
* <p>
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index a5a93c19ef..33672517fe 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -36,6 +36,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.BrowserEvents;
import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
@@ -5580,16 +5581,24 @@ public class Grid<T> extends ResizeComposite implements
c));
}
}
+ WidgetUtil.setTextSelectionEnabled(Document
+ .get().getBody(), false);
}
@Override
public void onComplete() {
fireEvent(new ColumnResizeEvent<T>(col));
+
+ WidgetUtil.setTextSelectionEnabled(Document
+ .get().getBody(), true);
}
@Override
public void onCancel() {
col.setWidth(initialWidth);
+
+ WidgetUtil.setTextSelectionEnabled(Document
+ .get().getBody(), true);
}
});
dragger.addTo(td);