[Gambas-user] TextEdit could do with RichTextPos

Bruce Steers bsteers4 at gmail.com
Wed Jun 15 13:35:15 CEST 2022


Been playing with Textedit from qt5.ext trying to make a simple RichText
editor.

It would be REALLY useful if there was a way to get the cursor position
relevant to the RichText property too.

Ie..
If i set my RichText to *"<font color=red>This message is red</font>" *and
i position the cursor on the m of the word message
then Pos is 5 and TextEdit1.Text is just "This message is red"

But the RichText property will now be this...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "
http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><meta
http-equiv="Content-Type" content="text/html; charset=utf-8" /><style
type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Ubuntu'; font-size:12pt;
font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="
color:#008000;">This message is green</span></p></body></html>

And the cursor Pos there is not 5 it is 529

If i want to do anything fancy with modifying the Richtext or detecting
styles/colors at cursor pos having a way to get a Richtext position
relative to the cursor would be very useful.

Or having a way to get some info about the text at cursor Ie.
TextEdit1.GetAttribs(Pos) could get info like font/size/color/etc
I feel i could write it myself but not without finding where the cursor is
in the Richtext.

Or is this all just not possible?
Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220615/e1ec3c0e/attachment.htm>


More information about the User mailing list