Copy content from one TextArea to another

  1. 4 weeks ago

    Arnaud N

    Nov 19 Pre-Release Testers, Xojo Pro

    Hello,

    I have 2 TextAreas, both having the same properties/subclass; only differences: one will be read-only and not shown (I need an offscreen one for printing purposes).
    When the user wants to print, from the visible and (for him) single TextArea, I must duplicate the whole content of the first TextArea to the second one, including styles, in order to preserve the initial text; then I replace variables with their values in the 2nd TextArea and print it.

    My problem lies in how to transfer the styled information from one TextArea to the other. The “easy” way doesn't quite work, for obscure reasons: using “TAMailing(1).StyledText.RTFData=TAMailing(0).StyledText.RTFData” results in the 2nd TextArea being “lighter”, while the fonts, sizes and other styles are still preserved… Looks like the RTFData mangles something not handled by Xojo.
    The other way I think of would be to loop thru all the styles and re-apply them to the other field; it looks like a pain and too much work for something an assignment should be enough.
    Am I missing something?

  2. 3 weeks ago

    Arnaud N

    Nov 26 Pre-Release Testers, Xojo Pro
    Edited 3 weeks ago

    I tried further using a loop and copying each StyleRun, first deleting all StyleRuns in the destination TextArea and get the same result as copying the RTFData: some texts get lighter in the destination (see screenshot).

    -image-
    (the screenshot doesn't seem to work. I'm keeping it in my post so it's possible to see the actual picture on imgur)
    I guess it's related to the use of special characters, but, for the fix, I'm clueless.
    Help, please.

or Sign Up to reply!