473,388 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Detecting which context menu item was selected

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

Jun 29 '06 #1
3 3848
br*****@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.

--
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/
Jun 29 '06 #2
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.
Randy Webb wrote:
br*****@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.

--
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/


Jun 29 '06 #3
br*****@gmail.com wrote:
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/a...nce/events.asp
http://developer.mozilla.org/en/docs...Event_Handlers

I would just put them all in the code. Brute force, you know :-)

--
Bart

Jun 30 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
5
by: yxq | last post by:
Hi I am build vb6 Context menu extension, but how to determine which popup menu item(popupItem1 and popupItem2) was clicked? Thanks The code ' ' IContextMenu::QueryContextMenu '
4
by: Don Peters | last post by:
I can't seem to find an answer to this problem in spite of many searches. I have a VB.NET program that has a context menu popup event. In it I associate some menu items with their events, as...
8
by: Sameh Ahmed | last post by:
Hello there i have a context menu linmked to a listview control. I want the context mnu to appear ONLY when i right click on an item and not any place in listview. any ideas? Thanks in advance....
5
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or...
2
by: gilad | last post by:
Hi, I seem to be having a problem getting a context menu to work in Explorer. The menu item installs fine, but when I click it a message box should pop up indicating the command was received and...
2
by: travelrats | last post by:
Hi Here's my problem - I've been trying to figure this out for a while and ran out of ideas... <div> id1 contains <div> id2 (a geographical map) <div> id2 contains a context menu made out of...
4
by: Karl | last post by:
Hi all, I want to write an application that is launched from the context menu in Windows Explorer/Computer. That is to say, when I am browsing around my hard drive and get to any location I...
0
by: EvilProject | last post by:
Hi im writing a class of a context menu where each menu item is linked to a Tree Node. I have a click event (that belongs to the context menu class ,not the menu item class) that it's event...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.