TextArea: paste to display highlighted text?

We all know you can’t set individual background color (“highlighting”) for characters in a textarea. You can set the backcolor of the control, you can change the forecolor, etc. There are a lot of threads about workarounds, plugins that do it, etc. But why is that we can paste text with highlighting into a text area, and it displays just fine? If it can do that, why can’t XOJO make that available to us?

(Why would you WANT that, you ask? Imagine a text control which was showing a character-by-character diff to another piece of text. Highlighting is MUCH more visible than coloring the foreground).

Honestly for a text diff you’d be better to draw it yourself anyway instead of formatting the text. If you format the text it’ll go with the text if the user copies the text.

Edit: and have you ever tried to clear the highlight color on text when you don’t want it? holy crap the most difficult thing to do on OS X by far.

[quote=314718:@Micah Bly]We all know you can’t set individual background color (“highlighting”) for characters in a textarea. You can set the backcolor of the control, you can change the forecolor, etc. There are a lot of threads about workarounds, plugins that do it, etc. But why is that we can paste text with highlighting into a text area, and it displays just fine? If it can do that, why can’t XOJO make that available to us?

(Why would you WANT that, you ask? Imagine a text control which was showing a character-by-character diff to another piece of text. Highlighting is MUCH more visible than coloring the foreground).[/quote]

You are right, it is possible at least on Mac to paste highlighted text into a TextArea.

The catch is, the built-in RTFData interpreter does not know what to do with it. So it will simply be ignored, if you try to save it, or load it.

Why not file a feature request ?

Michel: I checked, and it also “works” on Windows. Did not check Linux.

I believe I did request that very thing, back around 2006. I did add a vote to a newer one I found from 2016. But the general reason I don’t file a lot of requests is that I don’t have much faith they will get acted on. (Please don’t attack me for it; it’s my opinion, based on my experience, I’m sure others have had different experiences.).

Tim: we override copy/paste into/out of the text area, so not concerned with that. Rolling a completely new control, that supports BiDi text, inline images, full cursor controls (eg, opt-shift-left to select one word to the left), highlighting, squiggle lines for misspellings, show invisibles, etc. is on option, to be sure. But at some point, the reason we use XOJO is because we don’t want to re-invent low-level system controls. Because time=money of course.

Faith is in the eyes of the great puppeteer.

As long as there is a request, there is a chance that the feature be implemented. You can also lobby the forum and ask other people to put points on the request to make it more visible to Xojo.

Now, I suspect there could be a way to get your outline with some hacking of the row clipboard content. Indeed the information for outline is in there, it is only a matter of knowing how Apple (or Microsoft) structures styled text. I doubt it is out of reach from a careful examination, of, say, yellow outlined “A”. Once you know the encoding of outline, you can apply it to any string, and place it in the clipboard.

Then the trick would be to simulate the paste from the keyboard, with RemoteControlMBS or a declare. My own app Char Menu pastes styled text into apps that very same way.

I think MBS plugins may be able to save and load highlighted text. Christian will probably chime in.

I think something like NSTextViewMBS on Mac is susceptible to work.

I haven’t used it yet, but I kind of always assumed you could modify how TextInputCanvas would draw things on screen because it sounded like it was Canvas based.

[quote]@Michel Bujardet I think MBS plugins may be able to save and load highlighted text. Christian will probably chime in.

I think something like NSTextViewMBS on Mac is susceptible to work.[/quote]

I haven’t checked, but I agree. If a mac can do it, MBS will probably let you do it in XOJO. You can even use the built-in show invisibles feature. However, the problem is that most of our users are on Windows, so all of those beautiful NSxxx controls are out of reach.

And yes, a clipboard based hack is where I was going. I thought maybe somebody would have already tried it. Seems like it might work, or maybe you’ll get 95% of the way there and find out you can’t get it working.

MBS has the same as NSTextViewMBS for Windows : WinRTFDataMBS. I wish Christian was around to give more details.