• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Textarea Event Handling

 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When pasting content into a textarea I want to immediately evaluate "all" of the content in the textarea after a paste (using the mouse or key shortcut). How can I accomplish this? Onchange is not immediate enough, I need it to happen immediately following the paste when the content has already gone into the textarea. How can I accomplish this? The onpaste appears to happen before the content gets placed in the textarea. Any help would be appreciated.
 
Saloon Keeper
Posts: 28749
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess, you'll have to fake it. In your onPaste method:

1. Create 2 strings. One (s1) from the beginning of the content up to selectionStart. One (s3) containing the original context from selectionEnd to the end of data. This effectively snips out any selected text, which is what a paste would do. If there is no selection, selectionStart and selectionEnd should be the same, which is the current cursor (and presumed paste) postion.

2. Now you need to obtain the paste value string (s2), which should be in the clipboard.

3. Put them all together: s1 + s2 + s3 and you should end up with your post-paste control value.
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the answer (or type of answer) I wasn't hoping for :-) Thank you for the response, I'll give it a try. I was hoping that it be a more straightforward
 
reply
    Bookmark Topic Watch Topic
  • New Topic