summaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/terminal
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2008-03-13 13:50:41 +0000
committerMarc Englund <marc.englund@itmill.com>2008-03-13 13:50:41 +0000
commitbd4ff3bb1e6c385b0631469b75edc9d4f20d2d04 (patch)
tree56557c719c8d334dbeda0e66e2797f478e31db1e /src/com/itmill/toolkit/terminal
parent21b33561008c578ecb21ec360706f06f5fb4ecac (diff)
downloadvaadin-framework-bd4ff3bb1e6c385b0631469b75edc9d4f20d2d04.tar.gz
vaadin-framework-bd4ff3bb1e6c385b0631469b75edc9d4f20d2d04.zip
eventPreview fixed, should not interfere with modal window.
svn changeset:4036/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/terminal')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java68
1 files changed, 32 insertions, 36 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java
index 6931f93c89..8a703a7290 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/Notification.java
@@ -7,7 +7,6 @@ package com.itmill.toolkit.terminal.gwt.client.ui;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.EventPreview;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
@@ -35,12 +34,12 @@ public class Notification extends ToolkitOverlay {
private Timer fader;
private Timer delay;
- private EventPreview eventPreview;
- private String temporaryStyle;
private int x = -1;
private int y = -1;
+ private String temporaryStyle;
+
public Notification() {
setStylePrimaryName(STYLENAME);
sinkEvents(Event.ONCLICK);
@@ -59,7 +58,7 @@ public class Notification extends ToolkitOverlay {
}
public void startDelay() {
- DOM.releaseCapture(getElement());
+ DOM.removeEventPreview(this);
if (delayMsec > 0) {
delay = new Timer() {
public void run() {
@@ -102,36 +101,11 @@ public class Notification extends ToolkitOverlay {
addStyleName(style);
}
super.show();
- DOM.removeEventPreview(this);
setPosition(position);
-
- DOM.setCapture(getElement());
-
- if (style.equals("error")) {
- if (eventPreview == null) {
- eventPreview = new EventPreview() {
- public boolean onEventPreview(Event event) {
- Element target = DOM.eventGetTarget(event);
- if (DOM.isOrHasChild(getElement(), target)
- && DOM.eventGetType(event) == Event.ONCLICK) {
- startDelay();
- DOM.removeEventPreview(this);
- return true;
- } else {
- DOM.eventCancelBubble(event, true);
- return false;
- }
- }
- };
- }
-
- DOM.addEventPreview(eventPreview);
- }
-
}
public void hide() {
- DOM.releaseCapture(getElement());
+ DOM.removeEventPreview(this);
cancelDelay();
cancelFade();
if (temporaryStyle != null) {
@@ -142,7 +116,7 @@ public class Notification extends ToolkitOverlay {
}
public void fade() {
- DOM.releaseCapture(getElement());
+ DOM.removeEventPreview(this);
cancelDelay();
fader = new Timer() {
int opacity = startOpacity;
@@ -221,8 +195,28 @@ public class Notification extends ToolkitOverlay {
}
public void onBrowserEvent(Event event) {
- switch (DOM.eventGetType(event)) {
+ DOM.removeEventPreview(this);
+ if (fader == null) {
+ fade();
+ }
+ }
+
+ public boolean onEventPreview(Event event) {
+ int type = DOM.eventGetType(event);
+ // "modal"
+ if (delayMsec == -1) {
+ if (type == Event.ONCLICK
+ && DOM
+ .isOrHasChild(getElement(), DOM
+ .eventGetTarget(event))) {
+ fade();
+ }
+ return false;
+ }
+ // default
+ switch (type) {
case Event.ONMOUSEMOVE:
+
if (x < 0) {
x = DOM.eventGetClientX(event);
y = DOM.eventGetClientY(event);
@@ -231,12 +225,14 @@ public class Notification extends ToolkitOverlay {
startDelay();
}
break;
+ case Event.ONCLICK:
+ case Event.ONDBLCLICK:
+ case Event.KEYEVENTS:
+ case Event.ONSCROLL:
default:
- if (fader == null) {
- fade();
- }
- break;
+ startDelay();
}
+ return true;
}
}