diff options
author | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-05-26 15:57:16 +0300 |
---|---|---|
committer | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-05-27 15:52:46 +0300 |
commit | feab1153761049b4f833174586d158bef22eb15c (patch) | |
tree | a6dd004c9b861500ca0cf13ec9746e0a5287bfc2 /client | |
parent | 469a53e1256f143f506f8a3b59ef7fc505353495 (diff) | |
download | vaadin-framework-feab1153761049b4f833174586d158bef22eb15c.tar.gz vaadin-framework-feab1153761049b4f833174586d158bef22eb15c.zip |
Let mouse click move editor in unbuffered mode
Change-Id: I90a01ee7877aec35835145fb8b9c2dd49899dc5a
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index bf5494291f..4616c43902 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -1425,6 +1425,13 @@ public class Grid<T> extends ResizeComposite implements } } + protected void hide() { + hideOverlay(); + grid.getEscalator().setScrollLocked(Direction.VERTICAL, false); + state = State.INACTIVE; + updateSelectionCheckboxesAsNeeded(true); + } + protected void setGrid(final Grid<T> grid) { assert grid != null : "Grid cannot be null"; assert this.grid == null : "Can only attach editor to Grid once"; @@ -5063,7 +5070,7 @@ public class Grid<T> extends ResizeComposite implements sinkEvents(getHeader().getConsumedEvents()); sinkEvents(Arrays.asList(BrowserEvents.KEYDOWN, BrowserEvents.KEYUP, BrowserEvents.KEYPRESS, BrowserEvents.DBLCLICK, - BrowserEvents.MOUSEDOWN)); + BrowserEvents.MOUSEDOWN, BrowserEvents.CLICK)); // Make ENTER and SHIFT+ENTER in the header perform sorting addHeaderKeyUpHandler(new HeaderKeyUpHandler() { @@ -6306,31 +6313,43 @@ public class Grid<T> extends ResizeComposite implements } private boolean handleEditorEvent(Event event, RowContainer container) { + int type = event.getTypeInt(); + boolean editorIsActive = editor.getState() != Editor.State.INACTIVE; - if (editor.getState() != Editor.State.INACTIVE) { - if (event.getTypeInt() == Event.ONKEYDOWN + if (editorIsActive) { + // React to closing by keyboard in buffered and unbuffered mode + if (type == Event.ONKEYDOWN && event.getKeyCode() == Editor.KEYCODE_HIDE) { editor.cancel(); + return true; + } + // Swallow all other events in buffered mode and everything except + // ONCLICK in unbuffered mode + if (editor.isBuffered() || type != Event.ONCLICK) { + return true; } - return true; } if (container == escalator.getBody() && editor.isEnabled()) { - boolean wasOpen = editor.getState() != Editor.State.INACTIVE; boolean opened = false; - if (event.getTypeInt() == Event.ONDBLCLICK) { + if (editorIsActive && !editor.isBuffered() && type == Event.ONCLICK) { + editor.hide(); + cellFocusHandler.setCellFocus(eventCell); + editor.editRow(eventCell.getRowIndex()); + opened = true; + } else if (type == Event.ONDBLCLICK) { editor.editRow(eventCell.getRowIndex()); opened = true; - } else if (event.getTypeInt() == Event.ONKEYDOWN + } else if (type == Event.ONKEYDOWN && event.getKeyCode() == Editor.KEYCODE_SHOW) { editor.editRow(cellFocusHandler.rowWithFocus); opened = true; } if (opened) { - if (wasOpen) { + if (editorIsActive) { fireEvent(new EditorMoveEvent(eventCell)); } else { fireEvent(new EditorOpenEvent(eventCell)); |