Author: [EMAIL PROTECTED]
Date: Mon Sep 22 15:09:01 2008
New Revision: 3673
Modified:
trunk/user/src/com/google/gwt/user/client/ui/DialogBox.java
Log:
Fixed a bug in IE6 where the DialogBox would not drag unless the user
moused down directly over text in the caption. This patch was complicated
by the fact that we have an implicit contract to fire mouse listeners from
the caption into the DialogBox, which is really an implementation detail
but useful none the less. The get around this, the DialogBox now fires the
mouse events to itself, simulating the event from the caption.
Patch by: jlabanca
Review by: ecc (desk)
Issue: 2822
Modified: trunk/user/src/com/google/gwt/user/client/ui/DialogBox.java
==============================================================================
--- trunk/user/src/com/google/gwt/user/client/ui/DialogBox.java (original)
+++ trunk/user/src/com/google/gwt/user/client/ui/DialogBox.java Mon Sep 22
15:09:01 2008
@@ -68,6 +68,7 @@
private HTML caption = new HTML();
private boolean dragging;
private int dragStartX, dragStartY;
+ private MouseListenerCollection mouseListeners = new
MouseListenerCollection();
/**
* Creates an empty dialog box. It should not be shown until its child
widget
@@ -108,10 +109,11 @@
DOM.appendChild(td, caption.getElement());
adopt(caption);
caption.setStyleName("Caption");
- caption.addMouseListener(this);
+ mouseListeners.add(this);
// Set the style name
setStyleName(DEFAULT_STYLENAME);
+ sinkEvents(Event.MOUSEEVENTS);
}
public String getHTML() {
@@ -123,6 +125,29 @@
}
@Override
+ public void onBrowserEvent(Event event) {
+ super.onBrowserEvent(event);
+
+ // Only trigger mouse events if the event occurs in the caption wrapper
+ if (!dragging
+ && !getCellElement(0, 1).getParentElement().isOrHasChild(
+ event.getTarget())) {
+ return;
+ }
+
+ // Trigger a mouse event as if it originated in the caption
+ switch (event.getTypeInt()) {
+ case Event.ONMOUSEDOWN:
+ case Event.ONMOUSEUP:
+ case Event.ONMOUSEMOVE:
+ case Event.ONMOUSEOVER:
+ case Event.ONMOUSEOUT:
+ mouseListeners.fireMouseEvent(caption, event);
+ break;
+ }
+ }
+
+ @Override
public boolean onEventPreview(Event event) {
// We need to preventDefault() on mouseDown events (outside of the
// DialogBox content) to keep text from being selected when it
@@ -138,7 +163,7 @@
public void onMouseDown(Widget sender, int x, int y) {
dragging = true;
- DOM.setCapture(caption.getElement());
+ DOM.setCapture(getElement());
dragStartX = x;
dragStartY = y;
}
@@ -159,7 +184,7 @@
public void onMouseUp(Widget sender, int x, int y) {
dragging = false;
- DOM.releaseCapture(caption.getElement());
+ DOM.releaseCapture(getElement());
}
/**
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---