Prevent typing in upload panel
Change-Id: I4de309c15fa25388b2842d5e101ee0b83e439104
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/imagare/client/UploadByDropOrPastePanel.java b/src/main/java/com/googlesource/gerrit/plugins/imagare/client/UploadByDropOrPastePanel.java
index e521b20..e034e69 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/imagare/client/UploadByDropOrPastePanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/imagare/client/UploadByDropOrPastePanel.java
@@ -27,6 +27,7 @@
getElement().setAttribute("contenteditable", "true");
getElement().setAttribute("onpaste", "imagarePasteHandler(this, event)");
getElement().setAttribute("ondrop", "imagareDropHandler(this, event)");
+ getElement().setAttribute("onkeypress", "imagarePreventKeyPress(event)");
add(new Label("drag and drop image here"));
add(new Label("or"));
@@ -38,6 +39,14 @@
}-*/;
private static native void init0() /*-{
+ $wnd.imagarePreventKeyPress = function preventKeys(event) {
+ event = event || window.event;
+ var ctrlDown = event.ctrlKey || event.metaKey;
+ if (!ctrlDown) {
+ event.preventDefault();
+ }
+ }
+
$wnd.imagarePasteHandler = function handlePaste(elem, e) {
var savedContent = elem.innerHTML;