TGTextView textcolor

Dear ROOTers,

Is there a way to display colored text in a TGTextView? If so, how do I set the color?

Kind regards,
Marco van Woerden

I found this for changing the color of all the text.

colortext = new TGTextView(this,300,300,kLHintsExpandY|kLHintsRight); colortext->AddLine("LINE A"); colortext->SetForegroundColor(0xff0c0c); colortext->AddLine("LINE B");

This is nice, however it also changes the color of LINE A, because it updates all the lines. Is it even possible to have multiple colors in one TGTextView?

Hi Marco,

No, there is no way to change the color of only one part of the text inside a TGTextView. One alternative could be to use a TGHtml widget…

Cheers, Bertrand.

For anyone that might be interested, one can also try TLatex objects to create more lines of coloured text by using the syntax #color[color-number]{text}. Only drawback is that you seem to implement a TCanvas first.