diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2017-05-17 14:19:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-17 14:19:50 +0300 |
commit | 394299cd4cd5cddb08578aa758f927d3b40e3403 (patch) | |
tree | 30902492237b1ca722aca5776a040e41657b7b17 /client | |
parent | 6297a81c52107b8737fafe06a5ad472df9f3d567 (diff) | |
download | vaadin-framework-394299cd4cd5cddb08578aa758f927d3b40e3403.tar.gz vaadin-framework-394299cd4cd5cddb08578aa758f927d3b40e3403.zip |
Fix Button as a Html5 DragSource (#9346)
* Fix Button as a Html5 DragSourcei
It was completely broken, not being clickable, and also preventing anything else from being clicked.
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VButton.java | 28 | ||||
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/button/ButtonConnector.java | 11 |
2 files changed, 6 insertions, 33 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VButton.java b/client/src/main/java/com/vaadin/client/ui/VButton.java index 3bb6c5a1e8..611eb692cc 100644 --- a/client/src/main/java/com/vaadin/client/ui/VButton.java +++ b/client/src/main/java/com/vaadin/client/ui/VButton.java @@ -207,7 +207,7 @@ public class VButton extends FocusWidget implements ClickHandler { clickPending = true; setFocus(true); DOM.setCapture(getElement()); - isCapturing = isCapturingEnabled(); + isCapturing = true; addStyleName(CLASSNAME_PRESSED); } break; @@ -225,7 +225,7 @@ public class VButton extends FocusWidget implements ClickHandler { break; case Event.ONMOUSEMOVE: clickPending = false; - if (isCapturing) { + if (isCapturing && !isDraggable()) { // Prevent dragging (on other browsers); DOM.eventPreventDefault(event); } @@ -421,29 +421,13 @@ public class VButton extends FocusWidget implements ClickHandler { } /** - * Enables or disables the widget's capturing of mouse events with the mouse - * held down. - * - * @param enabled - * {@literal true} if capturing enabled, {@literal false} - * otherwise + * Returns if this button has been made <code>draggable</code> or not. * - * @since 8.1 - */ - public void setCapturingEnabled(boolean enabled) { - capturingEnabled = enabled; - } - - /** - * Returns if the widget's capturing of mouse events are enabled. - * - * @return {@literal true} if mouse capturing is enabled, {@literal false} + * @return {@literal true} if draggable is enabled, {@literal false} * otherwise - * - * @since 8.1 */ - public boolean isCapturingEnabled() { - return capturingEnabled; + private boolean isDraggable() { + return getElement().getPropertyBoolean("draggable"); } private static native int getHorizontalBorderAndPaddingWidth(Element elem) diff --git a/client/src/main/java/com/vaadin/client/ui/button/ButtonConnector.java b/client/src/main/java/com/vaadin/client/ui/button/ButtonConnector.java index f8e51a5dcc..b0d17465bb 100644 --- a/client/src/main/java/com/vaadin/client/ui/button/ButtonConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/button/ButtonConnector.java @@ -129,15 +129,4 @@ public class ButtonConnector extends AbstractComponentConnector } - @Override - public void onDragSourceAttached() { - // Disable mouse event capturing to make the widget draggable - getWidget().setCapturingEnabled(false); - } - - @Override - public void onDragSourceDetached() { - // Reset mouse event capturing - getWidget().setCapturingEnabled(true); - } } |