Cut/Paste Rich text on Mac/Safari TextArea

Discussion in 'Programmer Misc' started by cpprogrammer, May 11, 2006.

  1. cpprogrammer

    cpprogrammer Guest

    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?
     
    cpprogrammer, May 11, 2006
    #1
    1. Advertising

  2. cpprogrammer

    Jens Ayton Guest

    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
     
    Jens Ayton, May 11, 2006
    #2
    1. Advertising

  3. cpprogrammer

    cpprogrammer Guest

    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.
     
    cpprogrammer, May 14, 2006
    #3
  4. cpprogrammer

    cpprogrammer Guest

    Michael Ash wrote:
    > In comp.sys.mac.programmer.help cpprogrammer <>
    > 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.
     
    cpprogrammer, May 14, 2006
    #4
  5. cpprogrammer

    cpprogrammer Guest

    Michael Ash wrote:
    > In comp.sys.mac.programmer.misc cpprogrammer <>
    > 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.
     
    cpprogrammer, May 15, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter A

    Gmail Rich Text and Safari.

    Peter A, Jun 11, 2005, in forum: Apps
    Replies:
    2
    Views:
    87
    Peter A
    Jun 11, 2005
  2. Markus Zingg

    Displaying rich text format?

    Markus Zingg, Jul 7, 2004, in forum: Programmer Help
    Replies:
    4
    Views:
    135
    Thomas Engelmeier
    Jul 7, 2004
  3. cpprogrammer

    Cut/Paste Rich text on Mac/Safari TextArea

    cpprogrammer, May 11, 2006, in forum: Programmer Help
    Replies:
    5
    Views:
    1,223
    cpprogrammer
    May 15, 2006
  4. D.M. Procida

    Smart quotes in a Safari textarea box

    D.M. Procida, Mar 30, 2007, in forum: UK Macs
    Replies:
    6
    Views:
    324
    Chris Ridd
    Apr 3, 2007
  5. Martin S Taylor

    Rich Text in Mail.app

    Martin S Taylor, Jan 22, 2008, in forum: UK Macs
    Replies:
    47
    Views:
    269
    Woody
    Jan 24, 2008
Loading...

Share This Page