From: Jouni Koivuviita Date: Fri, 28 Aug 2009 09:02:59 +0000 (+0000) Subject: Fixes Button onClick event handling to support TestBench. X-Git-Tag: 6.7.0.beta1~2581 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=36e5bffae7ff6d63c04eccc94a902d4d2331cfea;p=vaadin-framework.git Fixes Button onClick event handling to support TestBench. Minor fixes to link-style Button base styles. svn changeset:8570/svn branch:6.1 --- diff --git a/WebContent/VAADIN/themes/base/button/button.css b/WebContent/VAADIN/themes/base/button/button.css index 31f091487c..47dffb5f86 100644 --- a/WebContent/VAADIN/themes/base/button/button.css +++ b/WebContent/VAADIN/themes/base/button/button.css @@ -105,14 +105,16 @@ .v-ie6 .v-nativebutton { width: 1px; } -.v-ie6 .v-nativebutton, -.v-ie7 .v-nativebutton, -.v-ie8 .v-nativebutton { +.v-ie .v-nativebutton { overflow: visible; padding-left: 1em; padding-right: 1em; } +.v-ie .v-nativebutton-link { + padding: 0; +} + /* * Checkbox styles * -------------------------------------- */ diff --git a/WebContent/VAADIN/themes/base/styles.css b/WebContent/VAADIN/themes/base/styles.css index fcd22a8afc..9bdd99a852 100644 --- a/WebContent/VAADIN/themes/base/styles.css +++ b/WebContent/VAADIN/themes/base/styles.css @@ -139,14 +139,16 @@ .v-ie6 .v-nativebutton { width: 1px; } -.v-ie6 .v-nativebutton, -.v-ie7 .v-nativebutton, -.v-ie8 .v-nativebutton { +.v-ie .v-nativebutton { overflow: visible; padding-left: 1em; padding-right: 1em; } +.v-ie .v-nativebutton-link { + padding: 0; +} + /* * Checkbox styles * -------------------------------------- */ diff --git a/WebContent/VAADIN/themes/reindeer/styles.css b/WebContent/VAADIN/themes/reindeer/styles.css index 78be75158f..8d51ea1262 100644 --- a/WebContent/VAADIN/themes/reindeer/styles.css +++ b/WebContent/VAADIN/themes/reindeer/styles.css @@ -139,14 +139,16 @@ .v-ie6 .v-nativebutton { width: 1px; } -.v-ie6 .v-nativebutton, -.v-ie7 .v-nativebutton, -.v-ie8 .v-nativebutton { +.v-ie .v-nativebutton { overflow: visible; padding-left: 1em; padding-right: 1em; } +.v-ie .v-nativebutton-link { + padding: 0; +} + /* * Checkbox styles * -------------------------------------- */ diff --git a/WebContent/VAADIN/themes/runo/styles.css b/WebContent/VAADIN/themes/runo/styles.css index a90b1a5a5d..79dab019b1 100644 --- a/WebContent/VAADIN/themes/runo/styles.css +++ b/WebContent/VAADIN/themes/runo/styles.css @@ -139,14 +139,16 @@ .v-ie6 .v-nativebutton { width: 1px; } -.v-ie6 .v-nativebutton, -.v-ie7 .v-nativebutton, -.v-ie8 .v-nativebutton { +.v-ie .v-nativebutton { overflow: visible; padding-left: 1em; padding-right: 1em; } +.v-ie .v-nativebutton-link { + padding: 0; +} + /* * Checkbox styles * -------------------------------------- */ diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButton.java b/src/com/vaadin/terminal/gwt/client/ui/VButton.java index b3213b1b8f..aaa615b305 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VButton.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VButton.java @@ -44,6 +44,10 @@ public class VButton extends FocusWidget implements Paintable { */ private boolean clickPending; + private boolean enabled = true; + + private int tabIndex = 0; + /* * BELOW PRIVATE MEMBERS COPY-PASTED FROM GWT CustomButton */ @@ -62,10 +66,8 @@ public class VButton extends FocusWidget implements Paintable { * Used to decide whether to allow clicks to propagate up to the superclass * or container elements. */ - private boolean allowClick; + private boolean disallowNextClick = false; private boolean isHovering; - private boolean enabled = true; - private int tabIndex = 0; public VButton() { super(DOM.createDiv()); @@ -178,17 +180,20 @@ public class VButton extends FocusWidget implements Paintable { } int type = DOM.eventGetType(event); + System.out.println(DOM.eventGetTypeString(event)); switch (type) { case Event.ONCLICK: // If clicks are currently disallowed, keep it from bubbling or // being passed to the superclass. - if (!allowClick) { + if (disallowNextClick) { event.stopPropagation(); + disallowNextClick = false; return; } break; case Event.ONMOUSEDOWN: if (event.getButton() == Event.BUTTON_LEFT) { + disallowNextClick = true; clickPending = true; setFocus(true); DOM.setCapture(getElement()); @@ -205,7 +210,8 @@ public class VButton extends FocusWidget implements Paintable { isCapturing = false; DOM.releaseCapture(getElement()); if (isHovering() && event.getButton() == Event.BUTTON_LEFT) { - onClick(); + // Click ok + disallowNextClick = false; } if (BrowserInfo.get().isIE() || BrowserInfo.get().isOpera()) { removeStyleName(CLASSNAME_PRESSED); @@ -309,15 +315,14 @@ public class VButton extends FocusWidget implements Paintable { // Allow the click we're about to synthesize to pass through to the // superclass and containing elements. Element.dispatchEvent() is // synchronous, so we simply set and clear the flag within this method. - allowClick = true; + + disallowNextClick = false; // Mouse coordinates are not always available (e.g., when the click is // caused by a keyboard event). NativeEvent evt = Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false); getElement().dispatchEvent(evt); - - allowClick = false; } /**