473,651 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3871
br*****@gmail.c om 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.javas cript 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.c om 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.javas cript 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.c om 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="update Box(this.value. length)"
ondblclick="upd ateBox(this.val ue.length)"
onmousedown="up dateBox(this.va lue.length)"
onmouseup="upda teBox(this.valu e.length)"
onmouseover="up dateBox(this.va lue.length)"
onmousemove="up dateBox(this.va lue.length)"
onmouseout="upd ateBox(this.val ue.length)"
onkeypress="upd ateBox(this.val ue.length)"
onkeydown="upda teBox(this.valu e.length)"
onkeyup="update Box(this.value. length)"
onfocus="update Box(this.value. length)"
onblur="updateB ox(this.value.l ength)"
onselect="updat eBox(this.value .length)"
onchange="updat eBox(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
3044
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 up, the window does not closes until I click on the window. Below is the code. Hopefully, you can help me out.
5
2693
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
3714
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 follows: ContextMenu1.MenuItems.Add("+1", New SystemEventHandler(AddressOf Me.Plus1)) ContextMenu1.MenuItems.Add("+2", New SystemEventHandler(AddressOf Me.Plus2))
8
429
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. PS: i want the same with treeviews Regards Sameh
5
2276
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 editor. I'd like to use the same default viewer/editor and open with... choices that are present on the users computer. Does anyone know how I can find this information programatically, so my picturebox context menu uses the same settings as the...
2
2747
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 handled. Unfortunately, nothing occurs. I suspect that I am doing something wrong with the command ID for the menu item, but I can't figure out what. After registering my DLL, the menu item "my context menu" appears if I right-click any file. If...
2
2445
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 an <ul> list. the context menu operations work fine, links are hovered, etc When I click one context menu items named "view large", <div> id2 is moved to another parent element, <div> id3 and resized. The move is performed using appendChild() It...
4
4206
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 choose, I want to be able to select several files, right click my mouse and launch an application which will act on the selected files. However, I don't even know where to start and have a number of questions!
0
1164
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 arguments contains a reference to the tree node linked to the menu item that was clicked. in the case that no menu item was selected, i want to fire this event with a null refrenced tree node.i could have done so if the collapse event of the context menu...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8697
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.