Skip navigation
Currently Being Moderated

How to copy Plain Text from TextFlow?

May 22, 2012 8:24 PM

Tags: #paste #copy

Hey guys,  I got stuck on Textflow copy-paste operation, I want to copy plain text from a textflow, don't want any text format/style but InlineGraphics, how can I do this?

 
Replies
  • Currently Being Moderated
    May 22, 2012 8:27 PM   in reply to liangyongning

    Please search Custom Clipboard inside TLF forum and blog.

    http://blogs.adobe.com/tlf/

     
    |
    Mark as:
  • Currently Being Moderated
    May 22, 2012 11:35 PM   in reply to liangyongning

    create a PlainTextExporter extends ConverterBase and implements ITextImporter, and

     

    TextConverter.addFormatAt(0, "plainText", PlainTextImporter);

    1. Did you create PlainTextExporter but register PlainTextImporter? I believe it must be a typo.

     

    2. What's more, the fifth paramter of addFormatAt should not be null when you take advantage of Custom Clipboard.

    /**

                         * Register a new format for import/export, at the specified location.

                         * Location can be significant for clients that have multiple

                         * choices for which format to use, such as when importing from the external clipboard.

                         * Lower numbers indicate higher priority; these converters will be tried first.

                         * The new format may support importing and/or exporting.

                         * If the format has already been added, then it will be present in multiple locations. The

                         * first one found will be used.

                         *

                         * @playerversion Flash 10

                         * @playerversion AIR 1.5

                         * @langversion 3.0

                         * @param importClass    The import converter class to register or null

                         * @param exportClass    The export converter class to register or null

                         * @param format         The format string tagging the converter classes

                         * @param clipboardFormat          The string used as the clipboard format when converting to/from the clipboard. Make this null if the format doesn't support clipboard access.

                         */

                        public static function addFormatAt(index:int, format:String, importerClass:Class, exporterClass:Class = null, clipboardFormat:String = null):void

     

    3. The example in blog only includes a importer. There can also be a exporter. Importer is called when you copy, while exporter when you paste.

    4. You must pay attention to the *if-condition* in importToFlow() of importer.

     
    |
    Mark as:
  • Currently Being Moderated
    May 23, 2012 10:41 PM   in reply to liangyongning

    Please pay attention to the bold words of item 2 in my last reply. You cannot miss the fifth paramter.

    TextConverter.addFormatAt(0, "plainText", PlainTextImporter, PlainTextExporter, "air:text");

     

    Is TextConverter influences the global copy behaviours in all TextFlows?

    Yes, but you can add if-conditions in importToFlow() to skip it under some circumstances.

     
    |
    Mark as:
  • Currently Being Moderated
    May 24, 2012 2:21 AM   in reply to liangyongning

    Maybe you can refer to the code of flashx.textLayout.conversion.TextConverter,  the default importers and exporters.

    The default clipboard is

    static tlf_internal function setFormatsToDefault():void

    {    

          _descriptors = [];     

         addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT);     

         addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null);     

         addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text");

     

    Besides, you may want to change the name of your class to avoid unexpected issues. You can see that there is already a TLF importer named PlainTextImporter.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points