diff options
author | Artur Signell <artur@vaadin.com> | 2014-04-04 14:08:25 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-04-04 12:46:43 +0000 |
commit | bf4cebc36c3efa6bbd42f16f30d6a06a4bf94527 (patch) | |
tree | 0f12948c224054f328d2e68afe26c8d359bba6ae /client | |
parent | ff4cce403e2b3a89726144d2e688024f8b12fcad (diff) | |
download | vaadin-framework-bf4cebc36c3efa6bbd42f16f30d6a06a4bf94527.tar.gz vaadin-framework-bf4cebc36c3efa6bbd42f16f30d6a06a4bf94527.zip |
Mousedown - mouseout - mouseover - mouseup now counts a click (#13550)
Change-Id: Id1f58b1ac6c207cec3357bcd96e1eb8d8de256a0
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VButton.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/client/src/com/vaadin/client/ui/VButton.java b/client/src/com/vaadin/client/ui/VButton.java index 840ed39114..98df258f57 100644 --- a/client/src/com/vaadin/client/ui/VButton.java +++ b/client/src/com/vaadin/client/ui/VButton.java @@ -225,10 +225,16 @@ public class VButton extends FocusWidget implements ClickHandler { DOM.eventPreventDefault(event); } break; + case Event.ONMOUSEOVER: + if (isCapturing && isTargetInsideButton(event)) { + // This means a mousedown happened on the button and a mouseup + // has not happened yet + setHovering(true); + addStyleName(CLASSNAME_PRESSED); + } + break; case Event.ONMOUSEOUT: - Element to = event.getRelatedTarget(); - if (getElement().isOrHasChild(DOM.eventGetTarget(event)) - && (to == null || !getElement().isOrHasChild(to))) { + if (isTargetInsideButton(event)) { if (clickPending && Math.abs(mousedownX - event.getClientX()) < MOVE_THRESHOLD && Math.abs(mousedownY - event.getClientY()) < MOVE_THRESHOLD) { @@ -236,8 +242,6 @@ public class VButton extends FocusWidget implements ClickHandler { break; } clickPending = false; - if (isCapturing) { - } setHovering(false); removeStyleName(CLASSNAME_PRESSED); } @@ -290,6 +294,15 @@ public class VButton extends FocusWidget implements ClickHandler { } } + /** + * Check if the event occurred over an element which is part of this button + */ + private boolean isTargetInsideButton(Event event) { + Element to = event.getRelatedTarget(); + return getElement().isOrHasChild(DOM.eventGetTarget(event)) + && (to == null || !getElement().isOrHasChild(to)); + } + final void setHovering(boolean hovering) { if (hovering != isHovering()) { isHovering = hovering; |