Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > onclick gets fired even when double clicked

Reply
Thread Tools

onclick gets fired even when double clicked

 
 
spinybabler
Guest
Posts: n/a
 
      08-07-2009
Hi,

Here is my problem: I have a image map. When i click an area on the
image map, the area is to be highlighted. This highlighting i achieve
by drawing a div over the image area. I have both click and double
click events defined for a image area. But when i double click on the
area, first onclick gets called which results in a div layer drawn
above the image area and thus double click event never gets called. Is
there any workaround to fix this?

Any help would be highly appreciated.

Thanks a lot.
 
Reply With Quote
 
 
 
 
Ivan S
Guest
Posts: n/a
 
      08-07-2009
On 7 kol, 20:13, spinybabler <(E-Mail Removed)> wrote:
> Hi,
>
> Here is my problem: I have a image map. When i click an area on the
> image map, the area is to be highlighted. This highlighting i achieve
> by drawing a div over the image area. I have both click and double
> click events defined for a image area. But when i double click on the
> area, first onclick gets called which results in a div layer drawn
> above the image area and thus double click event never gets called. Is
> there any workaround to fix this?
>
> Any help would be highly appreciated.
>
> Thanks a lot.


I had similar problem with one online game ... but I don't remember
solution.

Maybe you should ask this question on comp.lang.javascript group,
because this is javascript issue, not a html. Or try to find solution
on Google.




Ivan
 
Reply With Quote
 
 
 
 
spinybabler
Guest
Posts: n/a
 
      08-07-2009
On Aug 7, 2:21*pm, Ivan S <(E-Mail Removed)> wrote:
> On 7 kol, 20:13, spinybabler <(E-Mail Removed)> wrote:
>
> > Hi,

>
> > Here is my problem: I have a image map. When i click an area on the
> > image map, the area is to be highlighted. This highlighting i achieve
> > by drawing a div over the image area. I have both click and double
> > click events defined for a image area. But when i double click on the
> > area, first onclick gets called which results in a div layer drawn
> > above the image area and thus double click event never gets called. Is
> > there any workaround to fix this?

>
> > Any help would be highly appreciated.

>
> > Thanks a lot.

>
> I had similar problem with one online game ... but I don't remember
> solution.
>
> Maybe you should ask this question on comp.lang.javascript group,
> because this is javascript issue, not a html. Or try to find solution
> on Google.
>
> Ivan


I tried googling but only solution that I found was using setTimeout.
I made it to work but still it behaves awkwardly. Sometimes double
click gets called and sometimes it doesn't. The way i did it was to
setup a function that draws the div to be called after some time (400
millisecs). If double click gets called before that I remove the
timeout function call so that the div doesn't get drawn. It works but
I believe this is a dirty solution and the main thing is that it
doesn't work all the time.

Any inputs and directions where I should lead myself to??
 
Reply With Quote
 
richard
Guest
Posts: n/a
 
      08-08-2009
On Fri, 7 Aug 2009 11:13:05 -0700 (PDT), spinybabler
<(E-Mail Removed)> wrote:

>Hi,
>
>Here is my problem: I have a image map. When i click an area on the
>image map, the area is to be highlighted. This highlighting i achieve
>by drawing a div over the image area. I have both click and double
>click events defined for a image area. But when i double click on the
>area, first onclick gets called which results in a div layer drawn
>above the image area and thus double click event never gets called. Is
>there any workaround to fix this?
>
>Any help would be highly appreciated.
>
>Thanks a lot.



Look at the possibility of using ondoubleclick instead.
 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      08-08-2009

"spinybabler" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Here is my problem: I have a image map. When i click an area on the
> image map, the area is to be highlighted. This highlighting i achieve
> by drawing a div over the image area. I have both click and double
> click events defined for a image area. But when i double click on the
> area, first onclick gets called which results in a div layer drawn
> above the image area and thus double click event never gets called. Is
> there any workaround to fix this?
>
> Any help would be highly appreciated.
>
> Thanks a lot.



I would use onclick to run the function which immediately starts a clock and
sets a switch var. If after a short time the switch var has not changed then
run your div highlight code. If the function is called again before the
timed event (simulating a double-click) then change the switch var so that
this time when you reach the "after a short time" event it sees that the
switch var is different and runs the double-click code instead.

Make sense?


Andy

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Only every second fired event gets through to the handler K Viltersten ASP .Net 0 08-22-2009 07:05 PM
onclick gets fired even when double clicked spinybabler Javascript 1 08-07-2009 08:07 PM
Embedded <divs> with events: How to prevent the parent div's eventfrom being fired when the embedded div's event is fired? Num GG Javascript 2 11-17-2008 08:56 PM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM
event from dynamically loaded usercontrol gets fired once for 2 clicks Dan ASP .Net 0 11-16-2004 03:22 PM



Advertisments