| Author |
mouse event order in IE
|
seb petterson
Ranch Hand
Joined: Mar 04, 2005
Posts: 118
|
|
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
Joined: Mar 04, 2005
Posts: 118
|
|
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
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
The target object is in the event instance.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
seb petterson
Ranch Hand
Joined: Mar 04, 2005
Posts: 118
|
|
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
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
|
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
Joined: Mar 04, 2005
Posts: 118
|
|
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
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56192
|
|
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.
|
 |
 |
|
|
subject: mouse event order in IE
|
|
|