private native static void disableTextSelectInternal(Element e, boolean disable)/*-{
if (disable) {
e.ondrag = function () { return false; };
e.onselectstart = function () { return false; };
e.style.MozUserSelect="none"
} else {
e.ondrag = null;
e.onselectstart = null;
e.style.MozUserSelect="text"
}
}-*/;
@Override
public void onKeyDown(KeyDownEvent event) {
if (event.isShiftKeyDown()) {
disableTextSelectInternal(table.getElement(), true);
}
...
Friday, May 22, 2009
GWT disable text selection in an HTMLTable
While modifying FlexTable to handle cell selection It took me a while to figure out how to disable the native text selection behavior of the browsers on 'SHIFT+Click' events. Turns out this native javascript function does the job pretty well. I tried playing with event.preventDefault() and event.stopPropagation() but that didn't work.
Subscribe to:
Post Comments (Atom)
6 comments:
nice, succinct post. thanks!
And it works perfectly- thanks, saved me a lot of time
thanks! got it to work on firefox; need to test it on ie too :)
you are like god now !
thank you very much
спасибо!
spasibo
Post a Comment