wxRichTextCtrl GetStyle() bug?
Tom Gersic
wxdev at teleologic.net
Tue Jan 23 13:11:16 PST 2007
Hi,
I think there may be a bug with the wxRichTextCtrl GetStyle() command,
but I can't quite isolate it. What I'm trying to do is to look at a
particular location in the text (say, character 40), and check whether
the wxTEXT_ATTR_URL is set at that location. If it is set, I want to
find where that flag starts and ends (i.e. the beginning and end of the
link). So, I'm simply setting up a loop to search for the start position
of the link:
//for the purposes of this email, assume that characters 20
through 50 have wxTEXT_ATTR_URL set
int startLocation = 40;
wxRichTextAttr attr;
daTextCtrl->GetStyle(startLocation, attr);
while(attr.HasFlag(wxTEXT_ATTR_URL) && startLocation > 0)
{
startLocation--;
daTextCtrl->GetStyle(startLocation, attr);
}
wxMessageBox(wxString::Format("%d",startLocation));
Now, I know for a fact that the link starts at character 20, and extends
to character 50, so startPosition *should* equal 20, but it always goes
through the loop exactly once, and comes back with (in this instance)
19. If I add a watch for attr.HasFlag, it does indeed return true the
first time and false the second time I check....even if I don't subtract
1 from startLocation. So, for instance, if I do this twice...
daTextCtrl->GetStyle(startLocation, attr);
attr.HasFlag(wxTEXT_ATTR_URL) ;
...the first time it will return true, and the second time it will
return false.
What's going on here?
Thanks,
Tom
More information about the wx-dev
mailing list