By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,165 Members | 1,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,165 IT Pros & Developers. It's quick & easy.

cancelling shift-left-click event

P: n/a
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

Jun 18 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
jo***************@gmail.com wrote:
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

Jun 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.