summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2011-04-12 10:32:16 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2011-04-12 10:32:16 +0000
commitf63738e10ada9af16cd32b99a477b6398f665432 (patch)
tree20fea2b40352c7b9da0f9f1d688f02381cedca5d /src/com
parenta6197b4df19e4c93fec76821a9b627b4be0d25ca (diff)
downloadvaadin-framework-f63738e10ada9af16cd32b99a477b6398f665432.tar.gz
vaadin-framework-f63738e10ada9af16cd32b99a477b6398f665432.zip
reordering of columns on touch devices now work
svn changeset:18228/svn branch:6.6
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java55
1 files changed, 44 insertions, 11 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
index 8efd582fe6..68e692e8b4 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
@@ -1832,7 +1832,6 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
DOM.setElementProperty(colResizeWidget, "className", CLASSNAME
+ "-resizer");
- DOM.sinkEvents(colResizeWidget, Event.MOUSEEVENTS);
setText(headerText);
@@ -1848,11 +1847,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
// ensure no clipping initially (problem on column additions)
DOM.setStyleAttribute(captionContainer, "overflow", "visible");
- DOM.sinkEvents(captionContainer, Event.MOUSEEVENTS);
-
DOM.appendChild(td, captionContainer);
- DOM.sinkEvents(td, Event.MOUSEEVENTS);
+ DOM.sinkEvents(td, Event.MOUSEEVENTS | Event.TOUCHEVENTS);
setElement(td);
@@ -1944,7 +1941,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
if (enabled && event != null) {
if (isResizing
|| event.getEventTarget().cast() == colResizeWidget) {
- if (dragging && DOM.eventGetType(event) == Event.ONMOUSEUP) {
+ if (dragging
+ && (event.getTypeInt() == Event.ONMOUSEUP || event
+ .getTypeInt() == Event.ONTOUCHEND)) {
// Handle releasing column header on spacer #5318
handleCaptionEvent(event);
} else {
@@ -1957,7 +1956,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* variables from other components that fire variables when
* they lose focus.
*/
- if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
+ if (event.getTypeInt() == Event.ONMOUSEDOWN
+ || event.getTypeInt() == Event.ONTOUCHSTART) {
scrollBodyPanel.setFocus(true);
}
handleCaptionEvent(event);
@@ -2015,17 +2015,27 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
protected void handleCaptionEvent(Event event) {
switch (DOM.eventGetType(event)) {
+ case Event.ONTOUCHSTART:
case Event.ONMOUSEDOWN:
if (columnReordering) {
+ if (event.getTypeInt() == Event.ONTOUCHSTART) {
+ /*
+ * prevent using this event in e.g. scrolling
+ */
+ event.stopPropagation();
+ }
dragging = true;
moved = false;
colIndex = getColIndexByKey(cid);
DOM.setCapture(getElement());
headerX = tHead.getAbsoluteLeft();
- DOM.eventPreventDefault(event); // prevent selecting text
+ event.preventDefault(); // prevent selecting text &&
+ // generated touch events
}
break;
case Event.ONMOUSEUP:
+ case Event.ONTOUCHEND:
+ case Event.ONTOUCHCANCEL:
if (columnReordering) {
dragging = false;
DOM.releaseCapture(getElement());
@@ -2041,6 +2051,14 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
}
}
+ if (Util.isTouchEvent(event)) {
+ /*
+ * Prevent using in e.g. scrolling and prevent generated
+ * events.
+ */
+ event.preventDefault();
+ event.stopPropagation();
+ }
}
if (!moved) {
@@ -2067,18 +2085,33 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
rowRequestHandler.run(); // run immediately
}
fireHeaderClickedEvent(event);
+ if (Util.isTouchEvent(event)) {
+ /*
+ * Prevent using in e.g. scrolling and prevent generated
+ * events.
+ */
+ event.preventDefault();
+ event.stopPropagation();
+ }
break;
}
break;
+ case Event.ONTOUCHMOVE:
case Event.ONMOUSEMOVE:
if (dragging) {
+ if (event.getTypeInt() == Event.ONTOUCHMOVE) {
+ /*
+ * prevent using this event in e.g. scrolling
+ */
+ event.stopPropagation();
+ }
if (!moved) {
createFloatingCopy();
moved = true;
}
- final int x = DOM.eventGetClientX(event)
- + DOM.getElementPropertyInt(tHead.hTableWrapper,
- "scrollLeft");
+
+ final int clientX = Util.getTouchOrMouseClientX(event);
+ final int x = clientX + tHead.hTableWrapper.getScrollLeft();
int slotX = headerX;
closestSlot = colIndex;
int closestDistance = -1;
@@ -2100,7 +2133,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
}
tHead.focusSlot(closestSlot);
- updateFloatingCopysPosition(DOM.eventGetClientX(event), -1);
+ updateFloatingCopysPosition(clientX, -1);
}
break;
default: