Mac Help Forums


Reply
Thread Tools Display Modes

Cut/Paste Rich text on Mac/Safari TextArea

 
cpprogrammer
Guest
Posts: n/a
 
      11th May 2006
When I Copy/Paste Rich Text into a awt TextArea it behaves differently on
Windows XP as compared to Mac.

For eg. visit the following webpage

http://www.javacoffeebreak.com/java108/java108.html

There is a TextArea somewhere near the bottom.
Now mark some text from the webpage itself for eg.

For eg. I copied the following area from the webpage
---------------------------------------------------------------
TextField
Textfield components are useful for .....
...............
...............textfield will generate an event.

Example source
---------------------------------------------------------------

Now I paste it in the textarea in the applet - In windows,
"Example source" appears as plain text.
Where in Mac/OSX - the text "Example source" appears
as a link, just like it is in the webpage.

How do I disable this on Mac - i.e. I want the text stripped
& pasted as plain text.

I am using Java 1.5 on both platforms
IE is IE6

Safari is 1.2 (v125)
Mac is OSX 10.3.9

AWT docs on both Apple's site & Mac's site say that
it's supposed to be plain text, so why is it rendering
HTML?


 
Reply With Quote
 
 
 
 
Jens Ayton
Guest
Posts: n/a
 
      11th May 2006
cpprogrammer:
>
> When I Copy/Paste Rich Text into a awt TextArea it behaves differently on
> Windows XP as compared to Mac.

....
> AWT docs on both Apple's site & Mac's site say that
> it's supposed to be plain text, so why is it rendering
> HTML?


It isn't rendering HTML. It's rendering styled text -- attached URLs
can be part of text styling in OS X. For comparison, paste the same text
into TextEdit.

As for how to make it stop, I'm afraid I can't help you.


--
Jens Ayton
 
Reply With Quote
 
 
 
 
cpprogrammer
Guest
Posts: n/a
 
      14th May 2006
Jens Ayton wrote:
> cpprogrammer:
>>
>> When I Copy/Paste Rich Text into a awt TextArea it behaves
>> differently on Windows XP as compared to Mac.
>> For eg. visit the following webpage
>>
>> http://www.javacoffeebreak.com/java108/java108.html
>>
>> There is a TextArea somewhere near the bottom.
>> Now mark some text from the webpage itself for eg.
>>
>> For eg. I copied the following area from the webpage
>> ---------------------------------------------------------------
>> TextField
>> Textfield components are useful for .....
>> ..............
>> ..............textfield will generate an event.
>>
>> Example source
>> ---------------------------------------------------------------
>>
>> Now I paste it in the textarea in the applet - In windows,
>> "Example source" appears as plain text.
>> Where in Mac/OSX - the text "Example source" appears
>> as a link, just like it is in the webpage.
>>
>> How do I disable this on Mac - i.e. I want the text stripped
>> & pasted as plain text.
>>
>> I am using Java 1.5 on both platforms
>> IE is IE6
>>
>> Safari is 1.2 (v125)
>> Mac is OSX 10.3.9
>>
>> AWT docs on both Apple's site & Mac's site say that
>> it's supposed to be plain text, so why is it rendering
>> HTML?

>
> It isn't rendering HTML. It's rendering styled text -- attached URLs
> can be part of text styling in OS X. For comparison, paste the same
> text into TextEdit.



When I paste it into the Apple Works Word Processor, I see the colors
and all but I don't see the HTML Links. When I open Finder-> ShowClipboard
I see the colors but again I don't see the Links - the Clipboard shows
Contents
Text.

Only when I paste it to awt.TextArea do the links become active.
Even there, when I do TextArea.getText, I get plain text, without the
links & the formatting.

Why is Apple JVM's implementation of TextArea so non-standard
& going against it's own docs - I don't even find this non-standard
behaviour in the Microsoft 1.1. JVM.


>
> As for how to make it stop, I'm afraid I can't help you.



 
Reply With Quote
 
cpprogrammer
Guest
Posts: n/a
 
      14th May 2006
Michael Ash wrote:
> In comp.sys.mac.programmer.help cpprogrammer <(E-Mail Removed)>
> wrote:
>>>
>>> It isn't rendering HTML. It's rendering styled text -- attached
>>> URLs can be part of text styling in OS X. For comparison, paste the
>>> same text into TextEdit.

>>
>> When I paste it into the Apple Works Word Processor, I see the colors
>> and all but I don't see the HTML Links. When I open Finder->
>> ShowClipboard I see the colors but again I don't see the Links - the
>> Clipboard shows Contents
>> Text.

>
> This is because neither AppleWorks nor the Finder's clipboard viewer
> can display links in styled text (or if they can, they don't
> understand this OS-standard way). Try TextEdit as was originally
> suggested, and you will see that it (as well as any other Cocoa
> application with a standard text view) preserves links too.


Yes. TextEdit also shows it.

>
>> Only when I paste it to awt.TextArea do the links become active.
>> Even there, when I do TextArea.getText, I get plain text, without the
>> links & the formatting.
>>
>> Why is Apple JVM's implementation of TextArea so non-standard
>> & going against it's own docs - I don't even find this non-standard
>> behaviour in the Microsoft 1.1. JVM.

>
> I know nothing about Java, but it wouldn't surprise me if there was a
> certain amount of leeway allowed in the standard when implementing
> these things, and so including copied links was perfectly allowed.


I doubt it, especially, when both Sun & Apple's java docs say clearly
that TextArea is only for plain text.

> If
> you want to get rid of them, perhaps you can watch for text coming
> in, scan it for links, and strip them.


It doesn't show up in the TextArea.getText - which shows the
stripped text. So what happens is if I save the textarea content
to disk & load it next time there are no links - this leads to
a very confusing state for the user.


 
Reply With Quote
 
cpprogrammer
Guest
Posts: n/a
 
      15th May 2006
Michael Ash wrote:
> In comp.sys.mac.programmer.misc cpprogrammer <(E-Mail Removed)>
> wrote:
>>>
>>>> Only when I paste it to awt.TextArea do the links become active.
>>>> Even there, when I do TextArea.getText, I get plain text, without
>>>> the links & the formatting.
>>>>
>>>> Why is Apple JVM's implementation of TextArea so non-standard
>>>> & going against it's own docs - I don't even find this non-standard
>>>> behaviour in the Microsoft 1.1. JVM.
>>>
>>> I know nothing about Java, but it wouldn't surprise me if there was
>>> a certain amount of leeway allowed in the standard when implementing
>>> these things, and so including copied links was perfectly allowed.

>>
>> I doubt it, especially, when both Sun & Apple's java docs say clearly
>> that TextArea is only for plain text.

>
> Ah, that's my ignorace showing, my mistake. In that case it's
> definitely a bug, and you should file it at
> http://bugreport.apple.com .


Will do.

>
>>> If
>>> you want to get rid of them, perhaps you can watch for text coming
>>> in, scan it for links, and strip them.

>>
>> It doesn't show up in the TextArea.getText - which shows the
>> stripped text. So what happens is if I save the textarea content
>> to disk & load it next time there are no links - this leads to
>> a very confusing state for the user.

>
> Can you do the equivalent sort of action (getting the text and then
> setting it) after every paste? It seems like that sort of workaround
> should eliminate the links and then you're mostly ok, even if it is
> ugly code-wise.


I tried it, but then I lose the undo/redo history in the text area, so that
isn't a reasonable work around for me. Plus, it makes the textarea
flicker a lot.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mac OS X 10.5: Mail - Attachments not saved within a message when saving as rich text Newsbot Apple News 0 12th April 2008 01:41 AM
Cut/Paste Rich text on Mac/Safari TextArea cpprogrammer Programmer Help 5 15th May 2006 05:10 AM
Rich text signatures in Mail? Bonge Boo! UK Macs 4 13th April 2006 07:22 PM
Gmail Rich Text and Safari. Peter A Apps 2 11th June 2005 10:33 PM
Displaying rich text format? Markus Zingg Programmer Help 4 7th July 2004 11:45 PM


All times are GMT +1. The time now is 10:58 PM.
Mac-Help.com is an independent website and is not affiliated with Apple Inc.


Welcome!
Welcome to the Mac Help Forums
 


Latest Threads
I Mac Won't stay connected too new 2wire
Roncberry (2 Hours Ago, 08:17 PM)

New to Mac Help
Hemibee (5 Hours Ago, 05:07 PM)

Windows paint?
seloc (6 Hours Ago, 04:57 PM)

wifi drops out on my imac
tommysting (8 Hours Ago, 02:15 PM)

iPod and camera won't connect
Sprightly (16 Hours Ago, 06:10 AM)