cancelling shift-left-click event

J

jonathanmcdougall

I am developing a calendar on which dates can be clicked and selected.
A calendar is a table in which each day is a cell. Each cell has a
unique id.

By left-clicking on a date, it gets selected (with a blue background).
By then shift-left-clicking on another date, the range between the
first and second dates gets selected. This is a behavior commonly found
on GUI widgets. Therefore, I need to cancel the onMouseDown event so
the browser does not select the text by responding to shift-left-click
event. If I don't, the date cells get selected, but so is the text.

Simply returning false from the event handler works for Firefox but
doesn't for Internet Explorer 6. I tried setting cancelBubble to true
and returnValue to false to no avail. However, displaying an alert()
window prevents the selection, though I do not know if this is an
artifact from the window losing the focus. A post in this group
(http://tinyurl.com/g5au4) stated that "the alert is necessary for the
'return false' to properly work".

Setting a timer from onMouseDown to clear the selection does work, but
the selection is visible on screen for a fraction of second before
getting cleared. That's not a viable solution for me.

How do I prevent Internet Explorer (5.5+ if possible) from selecting
text when the user left-clicks with the shift key pressed?

Thank you,


Jonathan
 
J

Jonathan Mcdougall

I am developing a calendar on which dates can be clicked and selected.
A calendar is a table in which each day is a cell. Each cell has a
unique id.

By left-clicking on a date, it gets selected (with a blue background).
By then shift-left-clicking on another date, the range between the
first and second dates gets selected. This is a behavior commonly found
on GUI widgets. Therefore, I need to cancel the onMouseDown event so
the browser does not select the text by responding to shift-left-click
event. If I don't, the date cells get selected, but so is the text.

Simply returning false from the event handler works for Firefox but
doesn't for Internet Explorer 6. I tried setting cancelBubble to true
and returnValue to false to no avail. However, displaying an alert()
window prevents the selection, though I do not know if this is an
artifact from the window losing the focus. A post in this group
(http://tinyurl.com/g5au4) stated that "the alert is necessary for the
'return false' to properly work".

Setting a timer from onMouseDown to clear the selection does work, but
the selection is visible on screen for a fraction of second before
getting cleared. That's not a viable solution for me.

How do I prevent Internet Explorer (5.5+ if possible) from selecting
text when the user left-clicks with the shift key pressed?

Was that question off-topic or a faq? This newsgroup seems to be very
active and no answer could mean that's not a question you'd want to
answer or it was too difficult... just kiddin'.

Thanks for everybody's time anyways.


Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top