Page 1 of 1
RVGetSelection returns a different length if after a bullet
Posted: Thu Oct 20, 2022 6:02 pm
by jgkoehn
Greetings
I am using RVGetSelection(RichViewEdit, StartInt, LenInt, 2)
I select after the bullet for example:
No bullet:
20:1-10 test
The first with a bullet on LenInt returns 13
The second with NO bullet on LenInt returns 12
Perhaps this is intentional but the bullet is not being selected. Any ideas what is going on or how to make it with and without a bullet have the same length?
Re: RVGetSelection returns a different length if after a bullet
Posted: Thu Oct 20, 2022 6:20 pm
by jgkoehn
Nevermind, it is something else in my code. I am digging more.
Re: RVGetSelection returns a different length if after a bullet
Posted: Thu Oct 20, 2022 6:27 pm
by jgkoehn
Any ideas why moving the selection to stream then working with it in another RichViewEdit would change the length? (Specifically connected to bullet that hasn't been selected.)
ms := TMemoryStream.Create;
RVE.SaveRVFToStream(ms,True);
ms.Position := 0;
//Now switch to TempRVE
TempRVE.LoadRVFFromStream(ms);
TempRVE.Format;
ms.Clear;
GRichViewEdit := TempRVE;
GRichViewEdit.Style := TempRVE.Style; //Use incoming style
GCRVE := TempRVE.TopLevelEditor;
GCRVE.SelectAll;
Re: RVGetSelection returns a different length if after a bullet
Posted: Thu Oct 20, 2022 7:22 pm
by Sergey Tkachenko
Sorry, it changes the length of what?
Re: RVGetSelection returns a different length if after a bullet
Posted: Thu Oct 20, 2022 10:21 pm
by jgkoehn
Greetings Sergey,
Sorry let me combine my posts and make it clearer.
Code: Select all
GCRVE := RichViewEdit.TopLevelEditor;
//A user selects a portion of text right after a bullet point.
RVGetSelection(GCRVE, LinearStarPos, LinearLen, 2);//Get the Selection in linear instead of Bounds.
If VariableTrue then
begin
ms := TMemoryStream.Create;
RichViewEdit.SaveRVFToStream(ms,True);
ms.Position := 0;
//Now switch to TempRVE
TempRVE.LoadRVFFromStream(ms);
TempRVE.Format;
ms.Clear;
GRichViewEdit := TempRVE;
GRichViewEdit.Style := TempRVE.Style; //Use incoming style
GCRVE := TempRVE.TopLevelEditor;
GCRVE.SelectAll;
//It seems like if I do (This function instead of SelectAll it works better)
//RVSetSelection(GCRVE, 0, Abs(LinearLen), 2);
end;
RVGetSelection(GCRVE, StartInt, LenInt, 2);
If VariableTrue it uses a method to copy to a tempRichViewEdit and then to another for various reasons.
However, that process causes LenInt in RVGetSelection to be +1 in Length for example 13. If I turn VariableTrue = False and ignore this section then RVGetSelection LenInt = 12 it does not have the +1.
(I know it shifts between about 4 different RichViewEdits. There are odd reasons for that I probably could change that but ignoring that for now.)
I am thinking that the bullet point is partially getting copied somehow?
Re: RVGetSelection returns a different length if after a bullet
Posted: Thu Oct 20, 2022 11:31 pm
by standay
Sergey will know but my guess is if you are creating an rve, it gets created with one item in it. I think. If so, all you might have to do is clear it before putting data into it. I.e.,: TempRVE.Clear;
This is just a guess!
Stan
Re: RVGetSelection returns a different length if after a bullet
Posted: Fri Oct 21, 2022 12:02 am
by jgkoehn
A good guess Stan, I did try that but oddly enough it is only connected to when there is a bullet point. If there is none it is fine.