summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-10-05 11:23:46 +0300
committerVaadin Code Review <review@vaadin.com>2015-10-05 11:10:13 +0000
commit5097095625403405d030575fcc1102f02aa3e327 (patch)
tree99d68d5d570a33f6fb2435b4f7d68dc5c563641c /client
parent743095d97bbd632e0493fca29ba2308b17b86716 (diff)
downloadvaadin-framework-5097095625403405d030575fcc1102f02aa3e327.tar.gz
vaadin-framework-5097095625403405d030575fcc1102f02aa3e327.zip
Add support for TreeContextClickEvents (#19062)
Tree connector now overrides the send context click event providing the row key to the server-side via RPC call. This is then passed on to a TreeContextClickEvent and fired to listeners. This patch modifies the test base for context click testing by making it tolerate 1 piksel differences. This was to fix any subpixel related issues in coordinate comparison. Change-Id: Iacced274a6b518b5f89378cbc32b8381362e1e4f
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VTree.java5
-rw-r--r--client/src/com/vaadin/client/ui/tree/TreeConnector.java26
2 files changed, 29 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/ui/VTree.java b/client/src/com/vaadin/client/ui/VTree.java
index 3e51374dc7..8fcb01e5d5 100644
--- a/client/src/com/vaadin/client/ui/VTree.java
+++ b/client/src/com/vaadin/client/ui/VTree.java
@@ -1088,9 +1088,10 @@ public class VTree extends FocusElementPanel implements VHasDropHandler,
top += Window.getScrollTop();
left += Window.getScrollLeft();
client.getContextMenu().showAt(this, left, top);
+
+ event.stopPropagation();
+ event.preventDefault();
}
- event.stopPropagation();
- event.preventDefault();
}
}
diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
index b2babe9d52..842be9c4d3 100644
--- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java
+++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java
@@ -22,8 +22,11 @@ import java.util.Set;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.EventTarget;
+import com.google.gwt.event.dom.client.ContextMenuEvent;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
+import com.vaadin.client.MouseEventDetailsBuilder;
import com.vaadin.client.Paintable;
import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL;
@@ -33,9 +36,11 @@ import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.client.ui.VTree;
import com.vaadin.client.ui.VTree.TreeNode;
+import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.MultiSelectMode;
import com.vaadin.shared.ui.tree.TreeConstants;
+import com.vaadin.shared.ui.tree.TreeServerRpc;
import com.vaadin.shared.ui.tree.TreeState;
import com.vaadin.ui.Tree;
@@ -373,4 +378,25 @@ public class TreeConnector extends AbstractComponentConnector implements
return true;
}
+ @Override
+ protected void sendContextClickEvent(ContextMenuEvent event) {
+ EventTarget eventTarget = event.getNativeEvent().getEventTarget();
+ if (!Element.is(eventTarget)) {
+ return;
+ }
+
+ Element e = Element.as(eventTarget);
+ String key = null;
+ MouseEventDetails details = MouseEventDetailsBuilder
+ .buildMouseEventDetails(event.getNativeEvent());
+
+ if (getWidget().body.getElement().isOrHasChild(e)) {
+ TreeNode t = WidgetUtil.findWidget(e, TreeNode.class);
+ if (t != null) {
+ key = t.key;
+ }
+ }
+
+ getRpcProxy(TreeServerRpc.class).contextClick(key, details);
+ }
}