From 5ffd1309e1453871dc8c092c79b1016c88a805ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Tue, 2 Aug 2016 12:07:22 +0300 Subject: [PATCH] Start client-side Grid DOM event handling refactor Change-Id: I67dad4cfbd6e9e355c48703253ff3d6da00e4eef --- .../java/com/vaadin/client/widgets/Grid.java | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index e10035f9f7..5e33124405 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -7311,31 +7311,34 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, eventCell.set(cell, getSectionFromContainer(container)); // Editor can steal focus from Grid and is still handled - if (isEditorEnabled() && handleEditorEvent(event, container)) { + if (handleEditorEvent(event, container)) { return; } // Fire GridKeyEvents and GridClickEvents. Pass the event to escalator. - super.onBrowserEvent(event); + if (handleSuperEvent(event, container)) { + return; + } - if (!isElementInChildWidget(e)) { + if (handleChildWidgetEvent(event, container)) { + return; + } - if (handleHeaderCellDragStartEvent(event, container)) { - return; - } + if (handleHeaderCellDragStartEvent(event, container)) { + return; + } - // Sorting through header Click / KeyUp - if (handleHeaderDefaultRowEvent(event, container)) { - return; - } + // Sorting through header Click / KeyUp + if (handleHeaderDefaultRowEvent(event, container)) { + return; + } - if (handleRendererEvent(event, container)) { - return; - } + if (handleRendererEvent(event, container)) { + return; + } - if (handleCellFocusEvent(event, container)) { - return; - } + if (handleCellFocusEvent(event, container)) { + return; } } @@ -7389,6 +7392,10 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, } private boolean handleEditorEvent(Event event, RowContainer container) { + if (!isEditorEnabled()) { + return false; + } + Widget w; if (editor.focusedColumnIndex < 0) { w = null; @@ -7402,6 +7409,16 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, return getEditor().getEventHandler().handleEvent(editorEvent); } + private boolean handleSuperEvent(Event event, RowContainer container) { + super.onBrowserEvent(event); + return false; + } + + private boolean handleChildWidgetEvent(Event event, + RowContainer container) { + return isElementInChildWidget(Element.as(event.getEventTarget())); + } + private boolean handleRendererEvent(Event event, RowContainer container) { if (container == escalator.getBody()) { -- 2.39.5