• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

mouse event order in IE

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are the events I am hooking handlers to:
onmouseclick, onmousedblclick and onselectstart.

What I want to achieve is that the user can select text in table cells by double clicking the text thus selecting one word. But not selecting a huge chunk by pressing the SHIFT or CTRL keys, since these keys select the content in a way handled by javascript and table row highlighting, and the standard selection/highlighting of text overcolors my highlighting of the tablecells.

So: only selection through doublecklick.

I thought it would work by something like this:


But it seems as the order of the event handlers being called is weird (to me), namely: 1. onclick, 2. onselectstart, 3. ondblclick. So I don't know how to tell the onselectstart handler that the selection is triggered by a dblclick. How do I achivie this???

Thanks,

Seb

edit: changed keywords to onclic_k... due to forum filter.
[ September 13, 2007: Message edited by: seb petterson ]
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I could achieve this if I can get the object that was clicked (the table cell, or the span element that lays in it and which contains the double clicked text). I have the x y coordinates from the window.event.[x|y] ...anyone knows how to get the object?

Seb
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The target object is in the event instance.
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
The target object is in the event instance.



and how do i access it?
I tried:


also tried:

[ September 13, 2007: Message edited by: seb petterson ]
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you are paraphrasing your code, I don't know how you are really invoking your handlers. Please post actual code.
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Because you are paraphrasing your code, I don't know how you are really invoking your handlers. Please post actual code.



the actual code is a bit messy, but this will generate an alert saying undefined:

put anywhere in the script section:


or

or
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The usual pattern for event handlers:



Standards-compliant browsers will pass the event instance as the parameter to the handler. IE sets it as a property on window. The above idiom handles both cases. For real browsers, the target element will be identified as the target property in the event nstance, for IE, srcElement.

Or, you could do what most experienced developers do and employ a robust library such as jQuery or Prototype to handle all the browser differences for you.
 
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic