[Gambas-user] textedit html behaviour

Benoît Minisini gambas at ...1...
Wed Dec 2 21:03:24 CET 2009


> Benoît Minisini schreef:
> >>    Hi,
> >>    I wanted to use a textEdit window to be able to do things like
> >>  bold/colored text etc for individual lines.
> >>    I noticed this behavoir:
> >>        sText = "<b>Text</b>"
> >>        FLogfiles.txtMainLog.Text = sText
> >>    Displays:
> >>    Text
> >>        sText = "<b>Text</b>"
> >>        FLogfiles.txtMainLog.Insert(sText)
> >>    Displays:
> >>    <b>Text</b>
> >>    Is this expected behavior?
> >>    Gambas 2.18.x
> >>    gb.qt
> >>    Ubuntu 9.10
> >>    Regards,
> >>    Ron_2nd.
> >
> > Yes, why?
> 
> I would suspect that it doesn't matter how you supply content to an
> object (via .Text or .Insert() it should be displayed the same, now it
> doesn't, the content supplied with Insert() isn't parsed at all, as it
> displays all the html tags ins

Insert() inserts text as if you entered it with the keyboard. You cannot add 
HTML tags with that method.

TextEdit is not a HTML editor or viewer, it just use part of the HTML syntax 
when you define the Text property, that's all.

To insert formatted text, you must insert the text unformatted first, with the 
Insert method, then select it, and then use the Format property to format it.

> 
> I display my program logs inside 3 textAreas now, and I can simply set
> the cursor at last pos with .Pos = .Length and insert txt at the end
> without having it to append to a String variable which I have to create
> inside my program.
> 
> textEdit doesn't have a .Lenght property like textArea has, bit weird
> too, because the is a .Pos property...

Indeed. I think I didn't it because the Length property does not exist in Qt, 
and so I must compute the number of characters by hand.

> 
> With textEdit I can only do this if I keep a String variable myself and
> add to it, and set .Text to display the whole string everytime I open it.
> 
> On other thing (maybe hard to explain) I display the textAreas on a
> workspace, now if I close and reopen the form with the textAreas the
> content which I have inserted before is still there, with textEdit the
> areas start empty again.

Huh? Do you have a little project that shows this strange behaviour?

Regards,

-- 
Benoît Minisini




More information about the User mailing list