Search code examples
rubywxwidgetscopy-pastertewxruby

How do you copy and paste rich text to and from the wxRichTextCtrl?


I am using wxruby but as far as I can tell its not only a ruby problem. If I try to copy and paste rich text into the wxRichTextCtrl it loses all the formatting. What am I missing? Is there any way to make this work?


Solution

  • Looking at the SVN trunk code for richtextbuffer.cpp, in particular the method

    bool wxRichTextBuffer::PasteFromClipboard(long position)
    

    the control accepts exactly 4 different clipboard formats:

    • its own private format wxRichTextBufferDataObject::GetRichTextBufferFormatId()

    • standard text formats wxDF_TEXT and wxDF_UNICODETEXT

    • a bitmap format wxDF_BITMAP

    So it is indeed possible to copy and paste rich text between different or within a single wxRichTextCtrl, but there is no support for pasting RTF or similar data from external applications into a wxRichTextCtrl.