double click

109 views
Skip to first unread message

dusadrian

unread,
Jul 31, 2015, 8:24:36 AM7/31/15
to Raphaël
Hi everyone,

I have a Raphael object inside an HTML div.
While adding a .doubleclick event on the Raphael object, all the text inside the HTML div gets selected. Is there a way to disable this?

I tried:
$("#mydiv").doubleclick(function(event) { event.preventDefault() });

and also

myraphobj.doubleclick(function(event) { event.preventDefault() });

But none of them seem to work. I think it is because Raphael interprets the doubleclick event before jQuery, and the preventDefault() function never reaches jQuery to execute... I might be wrong on this but this is my hypothesis.

Anyways, does anyone has a solution for this?
Thanks,
Adrian

dusadrian

unread,
Jul 31, 2015, 8:25:57 AM7/31/15
to Raphaël, dusa....@gmail.com
I meant of course:

myraphobj.dblclick(function(event) { event.preventDefault() });

Ian

unread,
Jul 31, 2015, 8:35:07 AM7/31/15
to Raphaël, dusa....@gmail.com
Could you put your test case on a jsfiddle ?

dusadrian

unread,
Aug 1, 2015, 1:59:54 PM8/1/15
to Raphaël, dusa....@gmail.com, ibri...@gmail.com
Hi Ian,

I think I've managed to solve this, via a jQuery script:

$.extend($.fn.disableTextSelect = function() {
    return this.each(function(){
         $(this).mousedown(function(){return false;});
    });
});

Then, on the div that I want to disable the double click selection, I did:
$("#mydiv"). disableTextSelect();

That seems to work for both normal divs and those that contain Raphael papers.
I hope this helps anyone,
Adrian
Reply all
Reply to author
Forward
0 new messages