Avoid text selection when using double click listeners

We use double click listeners, especially in combination with tables and trees. Unfortunately, a double click sometimes selects text or surrounding whitespace which is not very appealing design-wise.

I attached a screenshot to illustrate what I mean. The selection of the text after the node “cat2_22” has been created by a double click on that row. We use double clicks in trees in order to open or close nodes. What’s worse is that during opening of the node, the selection actually flickers all over the tree…

I know text selection can be disabled via CSS but this disables text selection altogether and I wonder if there is a way to avoid the flickering and still enable the user to intentionally select text from the tree.

I ve never used
But maybe it is an option to call a clear selection jscript function in your double click listener.

function clearSelection() {
    if(document.selection && document.selection.empty) {
    } else if(window.getSelection) {
        var sel = window.getSelection();

Thanks! Looks good. I tested it in Chrome and Firefox and it works as expected. There is still flickering but that’s expected. One of the problems that occur when trying to impose desktop metaphors to the Web.