diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-10-13 18:07:55 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-10-14 13:46:13 +0000 |
commit | e6165e8e18f0aeea35071db60f82e7b1122c8253 (patch) | |
tree | 36dd2387c155f6b1237f18d5373de24d13fc97b7 /client | |
parent | a2b1860c163a26b92b8e2ca3ae227a27b75ca55c (diff) | |
download | vaadin-framework-e6165e8e18f0aeea35071db60f82e7b1122c8253.tar.gz vaadin-framework-e6165e8e18f0aeea35071db60f82e7b1122c8253.zip |
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
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/table/TableConnector.java | 25 |
1 files changed, 15 insertions, 10 deletions
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 |