The default behavior is to select an element for copying to clipboard
or dragging to the desktop. The element is left in a highlighted
state (partly transparent). When this happens, the DND stuff does not
work and I have to click someplace else to restore proper DND
behavior. This problem happens fairly frequently, say 10% of the time
or so.
I assume that this problem could be prevented by not allowing click &
drag events to "bubble up" to the browser. But so far my attempts to
do that have not fixed the problem.
I see this behavior on Safari, FF, and IE.
TIA
Rick
body {
-moz-user-select: element;
-khtml-user-select: element;
user-select: element;
}
.dragdrop-handle {
cursor: move;
-moz-user-select: none;
-khtml-user-select: none;
user-select: none;
}
.dragdrop-dropTarget.dragdrop-engage {
-moz-user-select: none;
-khtml-user-select: none;
user-select: none;
}
The problem is indeed the browser's default behavior for selection/
drag of Images and Text. Although there are several alleged
"solutions" involving CSS style properties (-no-user-select, no-
select, etc.) none of those work. I also tried the 'onselectionstart
= function() { return false;}' technique, that didn't work either.
After nearly giving up, I finally found the solution (see
http://groups.google.com/group/Google-Web-Toolkit/msg/482e37b79cd5ab3b).
Here is all I had to do:
-----------------------------
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Image;
public class UnselectableImage extends Image {
public void onBrowserEvent(Event event) {
if ((DOM.eventGetType(event) & (Event.MOUSEEVENTS |
Event.BUTTON_LEFT)) != 0) {
DOM.eventPreventDefault(event);
}
// Don't forget to allow the normal event handling to occur.
super.onBrowserEvent(event);
}
}
-----------------------------
Just use this class instead of 'Image' class for things that you don't
want the default browser select/drag to screw things up.
Now everything works perfectly!
Ciao,
Rick
> On 6/12/07, RickD <radun...@mac.com> wrote:
>
>
>
>
>
> > In general, the DND library has worked well for me. But I am
> > experiencing anomalies which I think are a result of default browser
> > click & drag behavior.
>
> > The default behavior is to select an element for copying to clipboard
> > or dragging to the desktop. The element is left in a highlighted
> > state (partly transparent). When this happens, the DND stuff does not
> > work and I have to click someplace else to restore proper DND
> > behavior. This problem happens fairly frequently, say 10% of the time
> > or so.
>
> > I assume that this problem could be prevented by not allowing click &
> > drag events to "bubble up" to the browser. But so far my attempts to
> > do that have not fixed the problem.
>
> > I see this behavior on Safari, FF, and IE.
>
> > TIA
>
> > Rick
>
> --
> Fred Sauer