Clipboard

1,240 views
Skip to first unread message

Chris

unread,
Jan 28, 2008, 10:56:45 PM1/28/08
to Google Web Toolkit
I see that when you highlight part of a website (including links,
images, etc.) and copy it to the clipboard, you get very different
results depending on which program you paste into (What gets pasted in
Notepad looks a lot different than what gets pasted in MS Word, which
looks different than what gets pasted in an HTML editor). I'd like to
know how you can use GWT to see ALL of the content that's stored on
the clipboard, before it's filtered by the program being pasted into.
Clearly when you paste into Notepad, and then paste into MS Word, you
see that Notepad filters out a lot of stuff. And I suspect that even
though MS Word preserves images and hyperlinks, it is filtering out
content that was stored on the clipboard as well.

What I'm trying to figure out is exactly what is being filtered out,
and what GWT methods can I use to access the unfiltered data?

I'm hoping some of the contents of the clipboard would help me in my
GWT app, but I'd like to see what they are first.

It would be help me if my GWT app knew the URL of the page from which
the content was copied from, does the clipboard store this?
Perhaps it also stores line numbers that indicate the beginning and
ending of the copied text from the original HTML file?
Perhaps the clipboard stores the name of the program from which the
content was copied? (Firefox, IE, etc.)

Any help would be appreciated. :)
Message has been deleted

Peter Blazejewicz

unread,
Feb 1, 2008, 6:50:12 PM2/1/08
to Google Web Toolkit
hi,

I think none of functionality you've wrote is available in javascript.
Appliaction within browser runs in "black-box" due to security
restrictions and doesn't have knowladge about system clipboard
content, its kind, etc, metadatas. We can't even use clipboard
programmatically accross browsers (I mean with simple "set" operation
to copy text to system clipboard),

regards
Peter

Chris

unread,
Feb 1, 2008, 7:19:13 PM2/1/08
to Google Web Toolkit
Thanks for your response Peter!

I'm wondering about situations where you paste into a GWT app using
Ctrl+v. It seems to me that in those situations, in a way you are
giving the javascript "permission" to operate outside of the "black-
box" it normally operates in.

Check out the example here:
http://examples.roughian.com/Widgets__RichTextArea.htm

If you copy and paste part of a website into the grey box on this
page, it'll keep images and hyperlinks intact. Also, if you press the
"Show HTML" button, it'll display the HTML of the content that you
pasted in the box. The HTML for the selected content seems to be
reproduced just like if you had clicked "Page Source" in your browser
on the original page (ie. it doesn't omit any tags like those for
flash file objects even though the RichTextBox can't reproduce that
content).

I'm used to being able to copy and paste plain text into websites, but
not Rich Text, so this is kind of new to me. I'm wondering if GWT can
be passed rich text stored on the clipboard as seen in the example I
described, then perhaps it can also be passed other content stored on
the clipboard as you are no longer limited to just copying and pasting
plain text. Perhaps it can even get at the metadata I was hoping
for. Any thoughts?

On Feb 1, 6:50 pm, Peter Blazejewicz <peter.blazejew...@gmail.com>
wrote:

Peter Blazejewicz

unread,
Feb 1, 2008, 7:29:19 PM2/1/08
to Google Web Toolkit
hi,
but that is different scenario, one doesn't use clipboard but access
Element.innerHTML property (DOM element property), How that is
impemented depends on browsers, but you are alwasy allow to get
content of your textarea using DOM.getInnerHTML(.....) method or other
method depending on what component you are usign,
I have read article about PITA when trying to copy/paste html-
formatted data accross html pages and to maintain it,
try:
http://ajaxian.com/archives/roxer-simple-web-page-creation-and-editing

regards,
Peter

Tushar

unread,
Mar 15, 2008, 12:04:55 PM3/15/08
to Google Web Toolkit
I open Notepad. type some text in it.
Select and copy it and then CTRL+v to paste it in RTA area. It shows.
I am using clipboard to do this.
That tells me that access to clipboard is there.
Just haven't figured out the details.

~ Tushar


On Feb 1, 8:29 pm, Peter Blazejewicz <peter.blazejew...@gmail.com>
wrote:
> hi,
> but that is different scenario, one doesn't useclipboardbut access
> > be passed rich text stored on theclipboardas seen in the example I
> > described, then perhaps it can also be passed other content stored on
> > theclipboardas you are no longer limited to just copying and pasting
> > plain text. Perhaps it can even get at the metadata I was hoping
> > for. Any thoughts?
>
> > On Feb 1, 6:50 pm, Peter Blazejewicz <peter.blazejew...@gmail.com>
> > wrote:
>
> > > hi,
>
> > > I think none of functionality you've wrote is available in javascript.
> > > Appliaction within browser runs in "black-box" due to security
> > > restrictions and doesn't have knowladge about systemclipboard
> > > content, its kind, etc, metadatas. We can't even useclipboard
> > > programmatically accross browsers (I mean with simple "set" operation
> > > to copy text to systemclipboard),
>
> > > regards
> > > Peter
>
> > > On Jan 29, 4:56 am, Chris <chris.armstr...@dreamhorizons.com> wrote:
>
> > > > I see that when you highlight part of a website (including links,
> > > > images, etc.) and copy it to theclipboard, you get very different
> > > > results depending on which program you paste into (What gets pasted in
> > > > Notepad looks a lot different than what gets pasted in MS Word, which
> > > > looks different than what gets pasted in an HTML editor). I'd like to
> > > > know how you can use GWT to see ALL of the content that's stored on
> > > > theclipboard, before it's filtered by the program being pasted into.
> > > > Clearly when you paste into Notepad, and then paste into MS Word, you
> > > > see that Notepad filters out a lot of stuff. And I suspect that even
> > > > though MS Word preserves images and hyperlinks, it is filtering out
> > > > content that was stored on theclipboardas well.
>
> > > > What I'm trying to figure out is exactly what is being filtered out,
> > > > and what GWT methods can I use to access the unfiltered data?
>
> > > > I'm hoping some of the contents of theclipboardwould help me in my
> > > > GWT app, but I'd like to see what they are first.
>
> > > > It would be help me if my GWT app knew the URL of the page from which
> > > > the content was copied from, does theclipboardstore this?
> > > > Perhaps it also stores line numbers that indicate the beginning and
> > > > ending of the copied text from the original HTML file?
> > > > Perhaps theclipboardstores the name of the program from which the

Axel Kittenberger

unread,
Mar 15, 2008, 8:01:21 PM3/15/08
to Google Web Toolkit
The JS doesn't "access" the clipboard, the browser is putting the
clipboard data into the richtext area when you hit ctrl+v, its the
browser that does things, not the javascript...

Chris

unread,
Mar 17, 2008, 3:45:37 PM3/17/08
to Google Web Toolkit
But the JS at least defines the rich text area so that the browser
understands that it's an area to paste rich text into, right?
When you copy something to the clipboard it gets stored in different
data flavors (plain text, rich text, HTML format, etc.).
If you can write JS so that the browser understands that the rich text
dataflavor is to be pasted into a text box, then perhaps you can have
other information from the clipboard pasted in? This is an example of
what gets stored on the clipboard when you copy something in Windows
that has an HTML format data flavor:

Version:0.9
StartHTML:00000129
EndHTML:00000298
StartFragment:00000163
EndFragment:00000262
SourceURL:http://www.imdb.com/
<html><body>
<!--StartFragment--><font face="Arial, Helvetica, sans-serif"
size="-1">
Welcome to the Internet Movie Database</font><!--EndFragment-->
</body>
</html>

I'd like the ability to paste all of this information into my GWT web
app.

Axel Kittenberger

unread,
Mar 17, 2008, 7:41:38 PM3/17/08
to Google Web Toolkit
The JS has no control over this. Just because it created the rich text
area, doesn't mean it can control paste events into it. You cannot do
what the browser doesn't give you.

Beside paste events into text boxes, there *are* possibilities to use
proprietary browser extensions to directly access the clipboard, but
its a pain. Any sane browser won't let you (would you want any html
page you browse being able to read your clipboard? Who knows what you
stored in it, and you really didn't want to paste it into the page
from mister X). But unsane/insecure browsers do, like Internet
Explorer. Firefox will require the user to add a specific patch and
aloweness to a webpage to directly access the clipboard. Its quite a
hassle for the user to install that. Opera/Safari I don't know if and
how it is possible...
Reply all
Reply to author
Forward
0 new messages