Tuesday, September 14, 2010

Re: clearing or preventing double-click selection

This works for preventing all selection on a widget.

addDomHandler(new MouseDownHandler()
{
@Override
public void onMouseDown(MouseDownEvent event)
{
event.preventDefault();
}
}, MouseDownEvent.getType());

On Sep 14, 3:53 am, Thomas Broyer <t.bro...@gmail.com> wrote:
> On Sep 12, 9:29 pm, decitrig <rws...@gmail.com> wrote:
>
> > I'm working on an application that responds to double clicks on text
> > labels, and I'd like to either disable double-click text selection or
> > clear it from within the event handler. I tried $doc.selection.clear()
> > in a native method, but apparently $doc.selection is "not an object" -
> > it may be that the selection isn't occurring until after the double-
> > click handler is getting called. I did try stopPropagation and
> > preventDefault, neither helped.
>
> > Any pointers?
>
> There's a CSS property that you can use to disable text selection:
> user-select.
> It's available in WebKit (-webkit-user-select) and Firefox (-moz-user-
> select). I can't tell for Opera (-o-user-select?).
> In IE, you'd have to listen to an onselectionstart event and cancel
> it.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment