473,385 Members | 1,655 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,385 software developers and data experts.

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

RBPierce
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 24356
pbmods
5,821 Expert 4TB
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 Expert Mod 8TB
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
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 Expert 1GB
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 Expert Mod 8TB
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
Thanks iam- I'll look into it!
Sep 6 '07 #7
pbmods
5,821 Expert 4TB
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
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
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
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...
5
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...
4
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,...
1
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...
6
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...
4
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...
0
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...
3
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...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...

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.