summaryrefslogtreecommitdiffstats
path: root/server/src/main
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@gmail.com>2017-06-28 13:41:46 +0300
committerGitHub <noreply@github.com>2017-06-28 13:41:46 +0300
commitcdefd5c3e5cbde20ac555099016fb7f249c3e1d9 (patch)
tree3764d07bff7958098ae33e74a2de35cab05e3e77 /server/src/main
parent29a4578a8d52c0720ff16cedf783223fdc4ea533 (diff)
downloadvaadin-framework-cdefd5c3e5cbde20ac555099016fb7f249c3e1d9.tar.gz
vaadin-framework-cdefd5c3e5cbde20ac555099016fb7f249c3e1d9.zip
Add mouse event details to Tree.ItemClick (#9599)
This provides a way to get the mouse button clicked as requested in #9335.
Diffstat (limited to 'server/src/main')
-rw-r--r--server/src/main/java/com/vaadin/ui/Tree.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Tree.java b/server/src/main/java/com/vaadin/ui/Tree.java
index cd53d1bc08..6ae86efe37 100644
--- a/server/src/main/java/com/vaadin/ui/Tree.java
+++ b/server/src/main/java/com/vaadin/ui/Tree.java
@@ -40,6 +40,7 @@ import com.vaadin.event.SerializableEventListener;
import com.vaadin.event.selection.SelectionListener;
import com.vaadin.server.ErrorMessage;
import com.vaadin.server.Resource;
+import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.grid.HeightMode;
@@ -101,6 +102,7 @@ public class Tree<T> extends Composite
public static class ItemClick<T> extends ConnectorEvent {
private final T item;
+ private final MouseEventDetails mouseEventDetails;
/**
* Constructs a new item click.
@@ -109,10 +111,15 @@ public class Tree<T> extends Composite
* the tree component
* @param item
* the clicked item
+ * @param mouseEventDetails
+ * information about the original mouse event (mouse button
+ * clicked, coordinates if available etc.)
*/
- protected ItemClick(Tree<T> source, T item) {
+ protected ItemClick(Tree<T> source, T item,
+ MouseEventDetails mouseEventDetails) {
super(source);
this.item = item;
+ this.mouseEventDetails = mouseEventDetails;
}
/**
@@ -129,6 +136,15 @@ public class Tree<T> extends Composite
public Tree<T> getSource() {
return (Tree<T>) super.getSource();
}
+
+ /**
+ * Returns the mouse event details.
+ *
+ * @return the mouse event details
+ */
+ public MouseEventDetails getMouseEventDetails() {
+ return mouseEventDetails;
+ }
}
/**
@@ -244,8 +260,8 @@ public class Tree<T> extends Composite
e.isUserOriginated()));
treeGrid.addCollapseListener(e -> fireCollapseEvent(
e.getCollapsedItem(), e.isUserOriginated()));
- treeGrid.addItemClickListener(
- e -> fireEvent(new ItemClick<>(this, e.getItem())));
+ treeGrid.addItemClickListener(e -> fireEvent(
+ new ItemClick<>(this, e.getItem(), e.getMouseEventDetails())));
}
/**