]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #2077: Button-click may be losed if button moves while clicking
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Tue, 23 Sep 2008 14:54:23 +0000 (14:54 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Tue, 23 Sep 2008 14:54:23 +0000 (14:54 +0000)
svn changeset:5488/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IButton.java

index 2d0c569daa33f4b9173274889f7a3c037efa4f2b..e2ca73e58c6c90f4d6bb84e169a08e25c1099f5e 100644 (file)
@@ -30,6 +30,8 @@ public class IButton extends Button implements Paintable {
 
     private Icon icon;
 
+    private boolean clickPending;
+
     public IButton() {
         setStyleName(CLASSNAME);
 
@@ -49,6 +51,8 @@ public class IButton extends Button implements Paintable {
             }
         });
         sinkEvents(ITooltip.TOOLTIP_EVENTS);
+        sinkEvents(Event.ONMOUSEDOWN);
+        sinkEvents(Event.ONMOUSEUP);
     }
 
     public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
@@ -123,6 +127,23 @@ public class IButton extends Button implements Paintable {
 
     public void onBrowserEvent(Event event) {
         super.onBrowserEvent(event);
+
+        // Handle special-case where the button is moved from under mouse
+        // while clicking it. In this case mouse leaves the button without
+        // moving.
+        if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
+            clickPending = true;
+        }
+        if (DOM.eventGetType(event) == Event.ONMOUSEMOVE) {
+            clickPending = false;
+        }
+        if (DOM.eventGetType(event) == Event.ONMOUSEOUT) {
+            if (clickPending) {
+                click();
+            }
+            clickPending = false;
+        }
+
         if (client != null) {
             client.handleTooltipEvent(event, this);
         }