From e6165e8e18f0aeea35071db60f82e7b1122c8253 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 13 Oct 2015 18:07:55 +0300 Subject: Support ContextClicks in empty areas of Table and TreeTable (#19130) When the user clicks an empty area, the TableContextClickEvent will still fire, but will have a null property. Change-Id: I39303f1a72d072db09c4fe6df8141d6caf0764c2 --- .../com/vaadin/client/ui/table/TableConnector.java | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java index badfcf7d28..a14ff15481 100644 --- a/client/src/com/vaadin/client/ui/table/TableConnector.java +++ b/client/src/com/vaadin/client/ui/table/TableConnector.java @@ -86,13 +86,12 @@ public class TableConnector extends AbstractFieldConnector implements protected void sendContextClickEvent(ContextMenuEvent event) { EventTarget eventTarget = event.getNativeEvent().getEventTarget(); if (!Element.is(eventTarget)) { - super.sendContextClickEvent(event); return; } Element e = Element.as(eventTarget); Section section; - String colKey; + String colKey = null; String rowKey = null; if (getWidget().tFoot.getElement().isOrHasChild(e)) { section = Section.FOOTER; @@ -102,15 +101,21 @@ public class TableConnector extends AbstractFieldConnector implements section = Section.HEADER; HeaderCell w = WidgetUtil.findWidget(e, HeaderCell.class); colKey = w.getColKey(); - } else if (getWidget().scrollBody.getElement().isOrHasChild(e)) { - section = Section.BODY; - VScrollTableRow w = getScrollTableRow(e); - rowKey = w.getKey(); - colKey = getWidget().tHead.getHeaderCell( - getElementIndex(e, w.getElement())).getColKey(); } else { - super.sendContextClickEvent(event); - return; + section = Section.BODY; + if (getWidget().scrollBody.getElement().isOrHasChild(e)) { + VScrollTableRow w = getScrollTableRow(e); + /* + * if w is null because we've clicked on an empty area, we will + * let rowKey and colKey be null too, which will then lead to + * the server side returning a null object. + */ + if (w != null) { + rowKey = w.getKey(); + colKey = getWidget().tHead.getHeaderCell( + getElementIndex(e, w.getElement())).getColKey(); + } + } } MouseEventDetails details = MouseEventDetailsBuilder -- cgit v1.2.3