How do I drop a styled text (and keep it styled) on a TextArea ?


I have a styled TextArea set to receive TextDrops,

I have a page with styled text in FireFox,

If I copy / Paste the styled text, I get it styled (in the target TextArea),

But, if I drag and drop it from Firefox onto my TextArea, I loose the styles.

So: how can I keep the styles when drag and drop styled text from Firefox ?

PS: I drop many other things (URL, Image, etc.) from FF to my StandAlone and doing to the application / Firefox and back many times is boring and vs my ideas on how a computer have to work ! ;-:slight_smile:

Ideas ?

I have a styled TextArea set to receive TextDrops,

Text is not the same as StyledText

P.S. This is a solution (not mine) from 2007 so might need some adapting:

in the open event of the Textarea I put the following:


In the dropobject event I put the following:

me.styledtext.RTFData = obj.RawData(“styl”)
me.text = obj.text

Assuming the Textarea is enabled when you drop the text, the dropped text is formatted.

P.P.S Just tried it: I have an EditField (not changing anything) and drop some styled text from Safari onto it.

Shows up fine (on my Mac).

Problem if non-ASCII characters are in there - formatting is moved. This is an old and immensely annoying bug in REALbasic / Xojo.

Drag/drop from FireFox: styles get lost.

This is also true when dragging&dropping into other apps (like Entourage or Word)

Hi Markus,

Test done with Xojo 2013r3.1.

Thank you for the tip.

Something is definitively wrong there. Without UseFocusRing enabled (in fact, it is enabled), I do not get styles at all, Copy / Paste retains some. I will try after enabling the focus ring:
BTW: UseFocusRing is enabled, but is not displayed (here).
Nahhh… I enabled AcceptsTabs (why can this be related ? It’s a simple test).

Firefox drops to TextEdit (from Apple): does not works. Even an image drop is rejected (it also holds the URL since the image is clickable).

Same as Firefox drops.
Image drop into a ListBox gets the target URL as intended.
Image drop in a Canvas gets the image as intended.

Safari drops to TextEdit (from Apple): works fine; both styled text and dropped images.

[quote=41247:@Markus Winter]> I have a styled TextArea set to receive TextDrops,

Text is not the same as StyledText[/quote]

In my mind, this was ‘generic’. But you are right.

On the other hand, Me.AcceptPictureDrop is generic too (or I do not found an error): I can drop any kind of Picture (TIFF, JPAG, PNG… whatever).

BTW: Xojo is not working consistently (watch what you have to do to save data to disk).

Styledtext as implemented in Xojo and previously in realbasic is a small subset of the styled text implemented by other apps (such as ms word) and via html in browsers. I have only had success with styledtext as generated and then read back within xojo. And as Emilie pointed out above, one non-ascii character can throw the entire block off. I wrote a zap routine to remove those characters, and replace them with a space. That helps.