diff options
author | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-06-08 12:54:15 +0300 |
---|---|---|
committer | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-06-08 12:54:15 +0300 |
commit | bfb632bf19f24beda9e0a5e4e6b3438cb532b069 (patch) | |
tree | d197e15b306ad0ac16f84a5e8c5f364941f1c4b7 /client | |
parent | acce09843e9fe1c26885dd09d723cbf0de969750 (diff) | |
download | vaadin-framework-bfb632bf19f24beda9e0a5e4e6b3438cb532b069.tar.gz vaadin-framework-bfb632bf19f24beda9e0a5e4e6b3438cb532b069.zip |
Fixes double-tap-to-open-editor issues
* Ignore double-taps on different rows
* Ignore swipe events
Change-Id: I37cccd6bda09a384b0698433adf3fa99985f1809
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 0941a1ea97..dbf7f98e37 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -3496,6 +3496,9 @@ public class Grid<T> extends ResizeComposite implements private boolean enabled = true; private double lastTouchEventTime = 0; + private int lastTouchEventX = -1; + private int lastTouchEventY = -1; + private int lastTouchEventRow = -1; private DetailsGenerator detailsGenerator = DetailsGenerator.NULL; private GridSpacerUpdater gridSpacerUpdater = new GridSpacerUpdater(); @@ -6440,14 +6443,29 @@ public class Grid<T> extends ResizeComposite implements final boolean closeEvent = event.getTypeInt() == Event.ONKEYDOWN && event.getKeyCode() == Editor.KEYCODE_HIDE; + double now = Duration.currentTimeMillis(); + int currentX = WidgetUtil.getTouchOrMouseClientX(event); + int currentY = WidgetUtil.getTouchOrMouseClientY(event); + + final boolean validTouchOpenEvent = event.getTypeInt() == Event.ONTOUCHEND + && now - lastTouchEventTime < 500 + && lastTouchEventRow == eventCell.getRowIndex() + && Math.abs(lastTouchEventX - currentX) < 20 + && Math.abs(lastTouchEventY - currentY) < 20; + final boolean openEvent = event.getTypeInt() == Event.ONDBLCLICK || (event.getTypeInt() == Event.ONKEYDOWN && event.getKeyCode() == Editor.KEYCODE_SHOW) - || (event.getTypeInt() == Event.ONTOUCHEND && now - - lastTouchEventTime < 500); + || validTouchOpenEvent; + + if (event.getTypeInt() == Event.ONTOUCHSTART) { + lastTouchEventX = currentX; + lastTouchEventY = currentY; + } if (event.getTypeInt() == Event.ONTOUCHEND) { lastTouchEventTime = now; + lastTouchEventRow = eventCell.getRowIndex(); } if (editor.getState() != Editor.State.INACTIVE) { |