I have a TEXTAREA element. A user right clicks within in to get the
context menu and they select "paste". I want my javascript code to
know that they selected "paste".
I know you can capture the mouse click, but can we capture exactly what
event that attempted?
Thanks,
Mike
brisco5@gmail.com said the following on 6/29/2006 4:54 PM:
> I have a TEXTAREA element. A user right clicks within in to get the
> context menu and they select "paste".
OK, but that is not the only way to "paste". There are at least 3 other
ways.
> I want my javascript code to know that they selected "paste".
Do you want to know they selected "paste" from that menu or that they
pasted text into your textarea? The difference in the two is astronomical.
> I know you can capture the mouse click, but can we capture exactly what
> event that attempted?
Doubtful, depending on what you are really trying to do.

Signature
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
brisco5@gmail.com - 29 Jun 2006 22:22 GMT
Ultimately, I'm trying to keep a running total of how many characters
are in the TEXTAREA. So really, however text can be entered, whether
it's keyed or pasted (context menu, control+v), I want to be able to
get the total.
> brisco5@gmail.com said the following on 6/29/2006 4:54 PM:
> > I have a TEXTAREA element. A user right clicks within in to get the
[quoted text clipped - 18 lines]
> Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
> Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
> I have a TEXTAREA element. A user right clicks within in to get the
> context menu and they select "paste". I want my javascript code to
> know that they selected "paste".
> I know you can capture the mouse click, but can we capture exactly what
> event that attempted?
I 'ld say you should use as much event handlers as possible then. The
following could be a start (but not complete!):
<script type="text/javascript">
function updateBox(nr) {
document.forms[0].howmany.value = nr
}
</script>
<form method="get">
<textarea name="txt" cols="30" rows="5"
onclick="updateBox(this.value.length)"
ondblclick="updateBox(this.value.length)"
onmousedown="updateBox(this.value.length)"
onmouseup="updateBox(this.value.length)"
onmouseover="updateBox(this.value.length)"
onmousemove="updateBox(this.value.length)"
onmouseout="updateBox(this.value.length)"
onkeypress="updateBox(this.value.length)"
onkeydown="updateBox(this.value.length)"
onkeyup="updateBox(this.value.length)"
onfocus="updateBox(this.value.length)"
onblur="updateBox(this.value.length)"
onselect="updateBox(this.value.length)"
onchange="updateBox(this.value.length)"
>
</textarea><br>
Length:
<input type="text" size="4" name="howmany" value="0">
</form>
Further handlers:
http://www.w3.org/TR/DOM-Level-2-Events/events.html
http://msdn.microsoft.com/workshop/author/dhtml/reference/events.asp
http://developer.mozilla.org/en/docs/DOM:element#Event_Handlers
I would just put them all in the code. Brute force, you know :-)

Signature
Bart