From e716b16b6162a90946a926eff3bfd2593f092b69 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 21 May 2012 12:26:20 +0000 Subject: Remove -webkit-overflow-scrolling from .v-scrollable for now - caused a weird iOS 5 bug in Accordion touch support (#8723 #8792) svn changeset:23770/svn branch:6.8 --- WebContent/VAADIN/themes/base/common/common.css | 1 - 1 file changed, 1 deletion(-) diff --git a/WebContent/VAADIN/themes/base/common/common.css b/WebContent/VAADIN/themes/base/common/common.css index f0b0f8e7be..8734aee63f 100644 --- a/WebContent/VAADIN/themes/base/common/common.css +++ b/WebContent/VAADIN/themes/base/common/common.css @@ -232,5 +232,4 @@ div.v-app-loading { .v-scrollable { overflow: auto; - -webkit-overflow-scrolling: touch; } \ No newline at end of file -- cgit v1.2.3 From 879e9aef4d6374ce89565460e0a979731f5da71f Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 21 May 2012 13:10:49 +0000 Subject: #8723 Remove superfluous sinkEvents() call svn changeset:23772/svn branch:6.8 --- src/com/vaadin/terminal/gwt/client/ui/VAccordion.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java b/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java index 4ff70d1668..20030d2d46 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VAccordion.java @@ -453,8 +453,6 @@ public class VAccordion extends VTabsheetBase implements touchScrollHandler.addElement(getContainerElement()); - sinkEvents(Event.MOUSEEVENTS); - close(); } -- cgit v1.2.3 From 9b52497261f0063b5a2d0431b8d7d61930a46161 Mon Sep 17 00:00:00 2001 From: Automerge Date: Mon, 21 May 2012 13:19:35 +0000 Subject: [merge from 6.7] Don't trigger actions if space or enter is pressed with Button focused (#7191) svn changeset:23774/svn branch:6.8 --- src/com/vaadin/terminal/gwt/client/ui/VButton.java | 37 +++++-------- src/com/vaadin/ui/Button.java | 3 -- .../button/ButtonEnterWithWindowShortcut.html | 62 ++++++++++++++++++++++ .../button/ButtonEnterWithWindowShortcut.java | 55 +++++++++++++++++++ 4 files changed, 129 insertions(+), 28 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/components/button/ButtonEnterWithWindowShortcut.html create mode 100644 tests/testbench/com/vaadin/tests/components/button/ButtonEnterWithWindowShortcut.java diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButton.java b/src/com/vaadin/terminal/gwt/client/ui/VButton.java index 98103dc41e..e77ad710b1 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VButton.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VButton.java @@ -77,7 +77,9 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, private boolean isCapturing; /** - * If true, this widget has focus with the space bar down. + * If true, this widget has focus with the space bar down. This + * means that we will get events when the button is released, but we should + * trigger the button only if the button is still focused at that point. */ private boolean isFocusing; @@ -91,8 +93,6 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, private HandlerRegistration focusHandlerRegistration; private HandlerRegistration blurHandlerRegistration; - private int clickShortcut = 0; - /** * If caption should be rendered in HTML */ @@ -174,10 +174,6 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, icon = null; } } - - if (uidl.hasAttribute("keycode")) { - clickShortcut = uidl.getIntAttribute("keycode"); - } } public void setText(String text) { @@ -316,37 +312,28 @@ public class VButton extends FocusWidget implements Paintable, ClickHandler, if ((event.getTypeInt() & Event.KEYEVENTS) != 0) { switch (type) { case Event.ONKEYDOWN: + // Stop propagation when the user starts pressing a button that + // we are handling to prevent actions from getting triggered if (event.getKeyCode() == 32 /* space */) { isFocusing = true; event.preventDefault(); + event.stopPropagation(); + } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) { + event.stopPropagation(); } break; case Event.ONKEYUP: if (isFocusing && event.getKeyCode() == 32 /* space */) { isFocusing = false; - - /* - * If click shortcut is space then the shortcut handler will - * take care of the click. - */ - if (clickShortcut != 32 /* space */) { - onClick(); - } - + onClick(); + event.stopPropagation(); event.preventDefault(); } break; case Event.ONKEYPRESS: if (event.getKeyCode() == KeyCodes.KEY_ENTER) { - - /* - * If click shortcut is enter then the shortcut handler will - * take care of the click. - */ - if (clickShortcut != KeyCodes.KEY_ENTER) { - onClick(); - } - + onClick(); + event.stopPropagation(); event.preventDefault(); } break; diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java index fdaef046e5..0032db1752 100644 --- a/src/com/vaadin/ui/Button.java +++ b/src/com/vaadin/ui/Button.java @@ -158,9 +158,6 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier, if (isDisableOnClick()) { target.addAttribute(VButton.ATTR_DISABLE_ON_CLICK, true); } - if (clickShortcut != null) { - target.addAttribute("keycode", clickShortcut.getKeyCode()); - } if (isHtmlContentAllowed()) { target.addAttribute("html-caption", true); diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonEnterWithWindowShortcut.html b/tests/testbench/com/vaadin/tests/components/button/ButtonEnterWithWindowShortcut.html new file mode 100644 index 0000000000..5ec33f09fa --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/button/ButtonEnterWithWindowShortcut.html @@ -0,0 +1,62 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.button.ButtonEnterWithWindowShortcut?restartApplication
pressSpecialKeyvaadin=runcomvaadintestscomponentsbuttonButtonEnterWithWindowShortcut::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]enter
assertTextvaadin=runcomvaadintestscomponentsbuttonButtonEnterWithWindowShortcut::PID_SLog_row_01. button click listener fired
pressSpecialKeyvaadin=runcomvaadintestscomponentsbuttonButtonEnterWithWindowShortcut::enter
assertTextvaadin=runcomvaadintestscomponentsbuttonButtonEnterWithWindowShortcut::PID_SLog_row_02. enter pressed in window
+ + diff --git a/tests/testbench/com/vaadin/tests/components/button/ButtonEnterWithWindowShortcut.java b/tests/testbench/com/vaadin/tests/components/button/ButtonEnterWithWindowShortcut.java new file mode 100644 index 0000000000..7efd40ca5d --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/button/ButtonEnterWithWindowShortcut.java @@ -0,0 +1,55 @@ +package com.vaadin.tests.components.button; + +import com.vaadin.event.Action; +import com.vaadin.event.Action.Handler; +import com.vaadin.event.ShortcutAction; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; + +public class ButtonEnterWithWindowShortcut extends TestBase { + Log log = new Log(5); + + @Override + protected void setup() { + getMainWindow().addActionHandler(new Handler() { + private static final long serialVersionUID = -4976129418325394913L; + + public void handleAction(Action action, Object sender, Object target) { + log.log(action.getCaption() + " pressed in window"); + } + + public Action[] getActions(Object target, Object sender) { + ShortcutAction enter = new ShortcutAction("enter", + ShortcutAction.KeyCode.ENTER, null); + ShortcutAction space = new ShortcutAction("space", + ShortcutAction.KeyCode.SPACEBAR, null); + return new Action[] { enter, space }; + } + }); + + Button button = new Button("Focus me and press enter", + new ClickListener() { + public void buttonClick(ClickEvent event) { + log.log("button click listener fired"); + } + }); + button.focus(); + + addComponent(log); + addComponent(button); + } + + @Override + protected String getDescription() { + return "Pressing enter or space with the button focused should trigger the button click listener and not the shortcut action on the window."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(5433); + } + +} -- cgit v1.2.3 From 233afce911a8f3c80ce86d9f46254a9c03c305d8 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 21 May 2012 13:53:47 +0000 Subject: #8724 Factored away duplicate code in native/non-native touch handling, removed unused variables, removed debug messages, added comments svn changeset:23775/svn branch:6.8 --- .../terminal/gwt/client/ui/VScrollTable.java | 148 +++++---------------- 1 file changed, 33 insertions(+), 115 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index bcd66c13f8..9e65889f44 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -4617,7 +4617,6 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, private String[] actionKeys = null; private final TableRowElement rowElement; - private boolean mDown; private int index; private Event touchStart; private static final String ROW_CLASSNAME_EVEN = CLASSNAME + "-row"; @@ -4628,6 +4627,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, private Timer dragTouchTimeout; private int touchStartY; private int touchStartX; + private boolean isDragging = false; private VScrollTableRow(int rowKey) { this.rowKey = rowKey; @@ -5038,40 +5038,24 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } } - private boolean wasSignificantMove = false; - private boolean isDragging = false; - /** - * Special handler for touch devices + * Special handler for touch devices that support native scrolling * - * @param event + * @return Whether the event was handled by this method. */ - public void onTouchBrowserEvent(final Event event) { - VConsole.log("-- START ONTOUCHBROWSEREVENT"); - if (enabled) { + private boolean handleTouchEvent(final Event event) { + + boolean touchEventHandled = false; + + if (enabled && hasNativeTouchScrolling) { final Element targetTdOrTr = getEventTargetTdOrTr(event); final int type = event.getTypeInt(); switch (type) { - case Event.ONCONTEXTMENU: - showContextMenu(event); - if (enabled - && (actionKeys != null || client - .hasEventListeners(VScrollTable.this, - ITEM_CLICK_EVENT_ID))) { - /* - * Prevent browser context menu only if there are - * action handlers or item click listeners - * registered - */ - event.stopPropagation(); - event.preventDefault(); - } - break; case Event.ONTOUCHSTART: + touchEventHandled = true; touchStart = event; isDragging = false; - wasSignificantMove = false; Touch touch = event.getChangedTouches().get(0); // save position to fields, touches in events are same // instance during the operation. @@ -5084,14 +5068,14 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, @Override public void run() { if (touchStart != null) { - VConsole.log("DRAGGING"); + // Start a drag if a finger is held + // in place long enough, then moved isDragging = true; } } }; - VConsole.log("START DRAG TIMEOUT"); - dragTouchTimeout.schedule(TOUCHSCROLL_TIMEOUT); } + dragTouchTimeout.schedule(TOUCHSCROLL_TIMEOUT); } if (actionKeys != null) { @@ -5100,54 +5084,51 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, @Override public void run() { if (touchStart != null) { - VConsole.log("SHOW CONTEXT"); + // Open the context menu if finger + // is held in place long enough. showContextMenu(touchStart); event.preventDefault(); - touchStart = null; - } } }; - VConsole.log("START CONTEXT TIMEOUT"); - - contextTouchTimeout.cancel(); - contextTouchTimeout - .schedule(TOUCH_CONTEXT_MENU_TIMEOUT); } + contextTouchTimeout + .schedule(TOUCH_CONTEXT_MENU_TIMEOUT); } break; case Event.ONTOUCHMOVE: + touchEventHandled = true; if (isSignificantMove(event)) { - wasSignificantMove = true; if (contextTouchTimeout != null) { + // Moved finger before the context menu timer + // expired, so let the browser handle this as a + // scroll. contextTouchTimeout.cancel(); + contextTouchTimeout = null; } if (!isDragging && dragTouchTimeout != null) { - VConsole.log("CANCEL DRAG TIMEOUT"); + // Moved finger before the drag timer expired, + // so let the browser handle this as a scroll. dragTouchTimeout.cancel(); dragTouchTimeout = null; } - if (isDragging) { - if (dragmode != 0 && touchStart != null) { - event.preventDefault(); - event.stopPropagation(); - VConsole.log("START DRAG"); - startRowDrag(touchStart, type, targetTdOrTr); - } - isDragging = false; + + if (dragmode != 0 && touchStart != null + && isDragging) { + event.preventDefault(); + event.stopPropagation(); + startRowDrag(touchStart, type, targetTdOrTr); } touchStart = null; } break; case Event.ONTOUCHEND: case Event.ONTOUCHCANCEL: - VConsole.log("ONTOUCHEND"); + touchEventHandled = true; if (contextTouchTimeout != null) { - VConsole.log("CANCEL CONTEXT TIMEOUT"); contextTouchTimeout.cancel(); } if (dragTouchTimeout != null) { - VConsole.log("CANCEL DRAG TIMEOUT"); dragTouchTimeout.cancel(); } if (touchStart != null) { @@ -5156,67 +5137,10 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, touchStart = null; } isDragging = false; - VConsole.log("END ONTOUCHEND"); break; - case Event.ONMOUSEDOWN: - VConsole.log("ONMOUSEDOWN"); - if (targetTdOrTr != null) { - setRowFocus(this); - ensureFocus(); - if (dragmode != 0 - && (event.getButton() == NativeEvent.BUTTON_LEFT)) { - startRowDrag(event, event.getTypeInt(), - targetTdOrTr); - } else { - event.stopPropagation(); - } - - event.preventDefault(); - } - break; - case Event.ONMOUSEOUT: - VConsole.log("ONMOUSEOUT"); - break; - case Event.ONMOUSEUP: - VConsole.log("ONMOUSEUP"); - if (targetTdOrTr != null) { - if (isSelectable()) { - boolean currentlyJustThisRowSelected = selectedRowKeys - .size() == 1 - && selectedRowKeys.contains(getKey()); - - if (!currentlyJustThisRowSelected) { - if (isSingleSelectMode() - || isMultiSelectModeDefault()) { - deselectAll(); - } - toggleSelection(); - } else if ((isSingleSelectMode() || isMultiSelectModeSimple()) - && nullSelectionAllowed) { - toggleSelection(); - } - - selectionRangeStart = this; - setRowFocus(this); - - event.preventDefault(); - event.stopPropagation(); - } - } - - break; - case Event.ONDBLCLICK: - if (targetTdOrTr != null) { - handleClickEvent(event, targetTdOrTr, true); - } - break; - default: } } - VConsole.log("-- SUPER ONBROWSEREVENT"); - - super.onBrowserEvent(event); - VConsole.log("-- END ONTOUCHBROWSEREVENT"); + return touchEventHandled; } /* @@ -5225,12 +5149,9 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, @Override public void onBrowserEvent(final Event event) { - if (hasNativeTouchScrolling) { - onTouchBrowserEvent(event); - return; - } + final boolean touchEventHandled = handleTouchEvent(event); - if (enabled) { + if (enabled && !touchEventHandled) { final int type = event.getTypeInt(); final Element targetTdOrTr = getEventTargetTdOrTr(event); if (type == Event.ONCONTEXTMENU) { @@ -5263,7 +5184,6 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, break; case Event.ONMOUSEUP: if (targetCellOrRowFound) { - mDown = false; /* * Queue here, send at the same time as the * corresponding value change event - see #7127 @@ -5507,7 +5427,6 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, break; case Event.ONMOUSEOUT: if (targetCellOrRowFound) { - mDown = false; } break; default: @@ -5538,7 +5457,6 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, protected void startRowDrag(Event event, final int type, Element targetTdOrTr) { - mDown = true; VTransferable transferable = new VTransferable(); transferable.setDragSource(VScrollTable.this); transferable.setData("itemId", "" + rowKey); -- cgit v1.2.3 From ac7031059125b41aef98d7920670022befeb55a6 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 21 May 2012 13:55:39 +0000 Subject: Removed an empty if() {} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn changeset:23776/svn branch:6.8 --- src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 9e65889f44..9aeeffe1f0 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -5426,8 +5426,6 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } break; case Event.ONMOUSEOUT: - if (targetCellOrRowFound) { - } break; default: break; -- cgit v1.2.3 From 12e35f034db98f5351c58c03b5277d4657e2ab28 Mon Sep 17 00:00:00 2001 From: Automerge Date: Mon, 21 May 2012 17:06:20 +0000 Subject: [merge from 6.7] Remove duplicate code in constructor svn changeset:23779/svn branch:6.8 --- src/com/vaadin/terminal/ClassResource.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/com/vaadin/terminal/ClassResource.java b/src/com/vaadin/terminal/ClassResource.java index fa196e90d9..e7419576f1 100644 --- a/src/com/vaadin/terminal/ClassResource.java +++ b/src/com/vaadin/terminal/ClassResource.java @@ -60,13 +60,7 @@ public class ClassResource implements ApplicationResource, Serializable { * the application this resource will be added to. */ public ClassResource(String resourceName, Application application) { - associatedClass = application.getClass(); - this.resourceName = resourceName; - this.application = application; - if (resourceName == null) { - throw new NullPointerException(); - } - application.addResource(this); + this(application.getClass(), resourceName, application); } /** -- cgit v1.2.3 From bec62403a7b56f093f5ee9829fea20ba3dee4628 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Tue, 22 May 2012 11:24:41 +0000 Subject: #8724 Properly generate simulated click events from touch events on iOS 5 svn changeset:23784/svn branch:6.8 --- src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 9aeeffe1f0..38c0ccce11 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -5088,6 +5088,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, // is held in place long enough. showContextMenu(touchStart); event.preventDefault(); + touchStart = null; } } }; @@ -5134,6 +5135,10 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, if (touchStart != null) { event.preventDefault(); event.stopPropagation(); + if (!BrowserInfo.get().isAndroid()) { + Util.simulateClickFromTouchEvent(touchStart, + this); + } touchStart = null; } isDragging = false; -- cgit v1.2.3