473,775 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capturing event when User right-click->paste into text box

RBPierce
7 New Member
Hey all, hoping someone can help me with a workaround. I've got an event set to fire when a textbox changes or loses focus- no problems. However, when the user clicks into the box and Right Click--> Pastes a value into it, I can't get any event to fire. I've tried onClick, OnChange, OnMouseDown, onMouseUp, onKeyDown, and onKeyUp.
Expand|Select|Wrap|Line Numbers
  1. <input type='text' onChange="alert('Changed')" onClick="alert('Clicked')" onMouseDown="alert('onMouseDown')" onMouseUp="alert('onMouseUp')" onKeyDown="alert('onKeyDown')" onKeyUp="alert('onKeyUp')">
I know I can do one of those stupid IE named scripts, but I was hoping someone somewhere had a multi-browser compliant solution!

http://msdn2.microsoft.com/en-us/library/ms536955.aspx
Sep 5 '07 #1
9 24422
pbmods
5,821 Recognized Expert Expert
Heya, RB. Welcome to TSDN!

Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Sep 5 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

Unfortunately, there's no reliable cross-browser way to capture a paste event. You can check this thread out. Why is it so important to capture this? Can you not just wait for onchange to fire when the text box loses focus?
Sep 5 '07 #3
RBPierce
7 New Member
Thanks PB!

acoder, upon successfully completing the input field in question, that value is then used to auto-complete various other fields on the page. If the user has to wait until they have tabbed/clicked to another input box in order for the auto-completion to kick in, we have violated GUI best practices by separating cause and effect.

Additionally, I have helper text in which prompts the user what is needed, i.e. "Start Date required". That text disappears after a valid date is entered... unless they mouse paste, in which case the text remains, while they can clearly see that a good date WAS entered.

Anyway, thanks for the help!
Sep 5 '07 #4
iam_clint
1,208 Recognized Expert Top Contributor
you can write a timer to check the value of the so called input box

Example provided.
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. var ival = "";
  3. var checkup = window.setInterval("checkChange();", 100);
  4. function checkChange() {
  5. var nval = document.getElementById("test").value;
  6. if (nval!=ival) { alert("change in the text"); ival=nval; }
  7. }
  8. </script>
  9. <input type="text" id="test" name="test" value="">
  10.  
Sep 5 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
acoder, upon successfully completing the input field in question, that value is then used to auto-complete various other fields on the page. If the user has to wait until they have tabbed/clicked to another input box in order for the auto-completion to kick in, we have violated GUI best practices by separating cause and effect.

Additionally, I have helper text in which prompts the user what is needed, i.e. "Start Date required". That text disappears after a valid date is entered... unless they mouse paste, in which case the text remains, while they can clearly see that a good date WAS entered.
Aah, that makes more sense. Well, iam_clint has posted a good workaround. Hopefully that should solve your problem.
Sep 6 '07 #6
RBPierce
7 New Member
Thanks iam- I'll look into it!
Sep 6 '07 #7
pbmods
5,821 Recognized Expert Expert
I wonder if you can use an onclick or maybe onrightclick (?) event handler that compares the current value of the textbox to the last value....

[EDIT: Just about the same thing iam_clint posted, except without the setInterval() call. Ah well.]
Sep 6 '07 #8
tushar chavan
1 New Member
Thanx ....
this was really helpful...

we can call the same function used to capture rest of mouse and key events(onkeyup, onblurr etc) .


this is wat i did for a multiline textbox to change the height dynamically

Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtdemo" runat="server" TextMode="MultiLine" Width="286px" onmouseup = "fnStartClock()" onkeydown="textAreaSize()" onblur="textAreaSize()" onfocus="textAreaSize()" onkeyup="textAreaSize()" height="16px" ></asp:TextBox>
Expand|Select|Wrap|Line Numbers
  1. ////////////////////////////////////////////////////
  2. function used for any event after clicking the mouse button called for a particular interval(for onmouseup and onmousedown)
  3. ///////////////////////////////////////////////////
  4. var oInterval;
  5. function fnStartClock(){
  6. if(oInterval!=null)
  7. {
  8.  window.clearTimeout(oInterval);
  9.  i=0;
  10.  }
  11.    oInterval = window.setInterval("textAreaSize()", 200); 
  12.  
  13. }
  14.  
  15. //////////////////////////////////////////////////
  16. here textAreaSize() is the function called for the rest of the events....
  17. it is used to change the height of a multiline textbox on entering a data 
  18. /////////////////////////////////////////////////
  19. var i=0;
  20.  
  21. function textAreaSize()
  22. {
  23.  
  24. var na= document.getElementById('ctl00_BodyContent_txtdemo')
  25.  
  26. var text = na.value.replace(/\s+$/g,'') ;  
  27. var split = text.split("\n");  
  28. var tbHeight = 16*split.length; 
  29. if(tbHeight>200)
  30. tbHeight=200
  31.    document.getElementById('ctl00_BodyContent_txtdemo").style.height = tbHeight;
  32.  i++;
  33.  if(i>100)
  34.  {
  35.  window.clearTimeout(oInterval);
  36.  i=0;
  37.  }
  38.  
  39. }
hope this is helpful.....
Dec 18 '09 #9
Thanks Clint, that was very helpful.
Sep 30 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5626
by: Earl Eiland | last post by:
Anyone know how to capture text from GUI output? I need to process information returned via a GUI window. Earl
0
1863
by: Brad Shook | last post by:
Ok here is what I a trying to do. I am trying to emulate an operator having to do repetitive tasks on a 3rd party program. Here is what I am doing so far. It works. Start Code Dim myProcess As Process = System.Diagnostics.Process.Start("C:\ca\wb.exe") myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal ' wait until the program is ready for input myProcess.WaitForInputIdle(1000) If myProcess.Responding Then
5
9611
by: TomTom | last post by:
Hi, With C#, is it possible to hover a mouse pointer on the Windows UI controls and show the UI text? For example, can I hover my mouse over "File" in the menu bar and show the text "File" on a label? I've seen a program like this but not sure if it can be done with C#. Thanks! TomTom
4
2793
by: Krishna Kumar | last post by:
Hai all, I am doing a project in .net and in that project I have a problem in capturing text from an image. i.e images like CAPTCHA images . which has inbuilt text with in the image.So, Can any one suggest me how to continue my work or give their valuable suggestions for capturing text in the CAPTCHA image . yours KrishnaKumar
1
1334
by: mwhite | last post by:
Hi, I need to find a way of capturing the text from a Word document, and storing it. Preferably as a string, as I then need to be able to manipulate the text in code and display it in my web app. Please help! Thanks in advance Mat
6
16111
by: ffreino | last post by:
Hi, I'm trying to capture text between two words in a multi-line string. For example: 89. This is the text I would like to capture. This is another line. 90. End of the example. I would like to capture text between the words (numbers in this case) '89' and '90'
4
1774
by: whizkid0000 | last post by:
Apologies for this query for i think it is pretty straightforward. (VB 6.0) Through a SQL query i have got a string which needs to be put in a textpad.(form code). Till now i am able to put data in dropdown(list down) boxes but not in textoad. The error its giving is invalid procedure call. A few code snippets i shall give to make the picture clearer. sQueryGetReviewer = "Select #### from #### where user_id = '" + UserName + "'" ' Get...
0
1143
by: krishnan2408 | last post by:
hi, I want to get all the text that is displayled in a java application window running in the unix OS. I am right now working in the X11::GuiTest module. Can anyone please suggest me any module(or function) to fulfill this requirement? If this is not possible, is it possible to capture the window into a .jpg file(say) and then get the text from it. Please suggest some modules which will work in the unix OS. I don't think the...
3
2220
by: mohanprasadgutta | last post by:
Hello, I want to capture the text being printed on console. problem description is as follows. I am calling called.pl program from caller.pl program using backticks. in called.pl program i am giving an external command to be executed in backticks. that external application will through a message to the console if any arguements are missing for that command. for example if we are not sending username and password(or wrong username and...
0
10270
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10109
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...
1
10051
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
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...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5360
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
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.