I'm using the workaround for being able to save styles in tables - i.e. saving to an intermediate TRichViewEdit that shares the same TRichViewStyle component at the final destination table (code at the bottom).
The problem is that when I then attempt to edit one of these cells the cursor cannot be positioned within the boudary of the first item. Words in the first item can be selected by double-clicking them but the cursor cannot be placed anywhere before the second item begins. If I select a word in the first item by double-clicking on it and, say, change its color, thus making this word the second item and words past this change the third item, EVERYTHING then behaves normally - including the remaining portion of what was the first item.
Could you give me some idea of what's wrong here?
try
MasterSecRVTable.Cells[i, 0].SaveRVFToStream(MemStream, False, clNone, nil, nil);
MemStream.Position := 0;
RichViewEdit3.LoadRVFFromStream(MemStream);
finally
MemStream.Clear;
end;
RichViewEdit3.Format;
try
RichViewEdit3.SaveRVFToStream(MemStream, False);
MemStream.Position := 0;
MasterRVTable.Cells[i + j, 1].AppendRVFFromStream(MemStream,-1,Dummy1,Dummy2);
finally
MemStream.Clear;
end;
Cannot Position Cursor Within Text
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
I had not been, after the initial Format when creating the table. However, I modified the code as below and it does not correct the problem. I have posted a small example file here
http://www.openwindow.com/ftp/cursorproblem.rvf
Perhaps you can tell by looking at it what is causing the problem. The entries in the FIRST three rows do NOT have the problem. The LAST three rows do.
Note that in the very last row, the red-colored word English DOES work correctly, as do the words following it.
ACTUALLY, you may not be able to SEE the problem! I notice that when I open the file with your example editor, RDemo, the problem isn't there - but whatever causes it in MY program is, because if I then close it in RDemo and re-open with my program the problem is still there.
Clearly I must be missing a step when I load the file??
Note - I don't have this problem during normal operation of the program - only when creating a file with the code section below do I have an issue.
Here's the code as it currently stands:
//Copy SecRVTable to MasterRVTableRVTable
j := MasterRVTable.Rows.Count - SecondaryMaxNumber;
MemStream := TMemoryStream.Create;
if ((Length(ForceCategoryString) > 0) and (Length(ForceCategoryString) < 26)) then //Strip tags
ForceCategoryString := Copy(ForceCategoryString,6,Length(ForceCategoryString)-6);
for i := 0 to SecondaryMaxNumber - 1 do
begin
RichViewEdit3.Clear;
RichViewEdit3.Format;
if ((Length(ForceCategoryString) > 0) and (Length(ForceCategoryString) < 26)) then
begin
MasterRVTable.Cells[i + j, 0].Clear;
MasterRVTable.Cells[i + j, 14].Clear;
MasterRVTable.Cells[i + j, 0].AddTextNLA(ForceCategoryString,0,0,0);
MasterRVTable.Cells[i + j, 14].AddTextNLA(ForceCategoryString,0,0,0);
end;
try
MasterSecRVTable.Cells[i, 0].SaveRVFToStream(MemStream, False, clNone, nil, nil);
MemStream.Position := 0;
RichViewEdit3.LoadRVFFromStream(MemStream);
finally
MemStream.Clear;
end;
RichViewEdit3.Format;
try
RichViewEdit3.SaveRVFToStream(MemStream, False);
MemStream.Position := 0;
MasterRVTable.Cells[i + j, 1].AppendRVFFromStream(MemStream,-1,Dummy1,Dummy2);
RichViewEdit1.Format;
finally
MemStream.Clear;
end;
RichViewEdit3.Clear;
RichViewEdit3.Format;
try
MasterSecRVTable.Cells[i, 1].SaveRVFToStream(MemStream, False, clNone, nil, nil);
MemStream.Position := 0;
RichViewEdit3.LoadRVFFromStream(MemStream);
finally
MemStream.Clear;
end;
RichViewEdit3.Format;
try
RichViewEdit3.SaveRVFToStream(MemStream, False);
MemStream.Position := 0;
MasterRVTable.Cells[i + j, 15].AppendRVFFromStream(MemStream,-1,Dummy1,Dummy2);
RichViewEdit1.Format;
finally
MemStream.Clear;
end;
end;
MemStream.Free;
end
http://www.openwindow.com/ftp/cursorproblem.rvf
Perhaps you can tell by looking at it what is causing the problem. The entries in the FIRST three rows do NOT have the problem. The LAST three rows do.
Note that in the very last row, the red-colored word English DOES work correctly, as do the words following it.
ACTUALLY, you may not be able to SEE the problem! I notice that when I open the file with your example editor, RDemo, the problem isn't there - but whatever causes it in MY program is, because if I then close it in RDemo and re-open with my program the problem is still there.
Clearly I must be missing a step when I load the file??
Note - I don't have this problem during normal operation of the program - only when creating a file with the code section below do I have an issue.
Here's the code as it currently stands:
//Copy SecRVTable to MasterRVTableRVTable
j := MasterRVTable.Rows.Count - SecondaryMaxNumber;
MemStream := TMemoryStream.Create;
if ((Length(ForceCategoryString) > 0) and (Length(ForceCategoryString) < 26)) then //Strip tags
ForceCategoryString := Copy(ForceCategoryString,6,Length(ForceCategoryString)-6);
for i := 0 to SecondaryMaxNumber - 1 do
begin
RichViewEdit3.Clear;
RichViewEdit3.Format;
if ((Length(ForceCategoryString) > 0) and (Length(ForceCategoryString) < 26)) then
begin
MasterRVTable.Cells[i + j, 0].Clear;
MasterRVTable.Cells[i + j, 14].Clear;
MasterRVTable.Cells[i + j, 0].AddTextNLA(ForceCategoryString,0,0,0);
MasterRVTable.Cells[i + j, 14].AddTextNLA(ForceCategoryString,0,0,0);
end;
try
MasterSecRVTable.Cells[i, 0].SaveRVFToStream(MemStream, False, clNone, nil, nil);
MemStream.Position := 0;
RichViewEdit3.LoadRVFFromStream(MemStream);
finally
MemStream.Clear;
end;
RichViewEdit3.Format;
try
RichViewEdit3.SaveRVFToStream(MemStream, False);
MemStream.Position := 0;
MasterRVTable.Cells[i + j, 1].AppendRVFFromStream(MemStream,-1,Dummy1,Dummy2);
RichViewEdit1.Format;
finally
MemStream.Clear;
end;
RichViewEdit3.Clear;
RichViewEdit3.Format;
try
MasterSecRVTable.Cells[i, 1].SaveRVFToStream(MemStream, False, clNone, nil, nil);
MemStream.Position := 0;
RichViewEdit3.LoadRVFFromStream(MemStream);
finally
MemStream.Clear;
end;
RichViewEdit3.Format;
try
RichViewEdit3.SaveRVFToStream(MemStream, False);
MemStream.Position := 0;
MasterRVTable.Cells[i + j, 15].AppendRVFFromStream(MemStream,-1,Dummy1,Dummy2);
RichViewEdit1.Format;
finally
MemStream.Clear;
end;
end;
MemStream.Free;
end
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact:
-
- Site Admin
- Posts: 17565
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Initially cells contain one empty text item of the 0th text and paragraph style.
-1 is not a valid value for ParaNo for the first cell item. So you cannot call Cell.AppendRVFFromStream(...,-1,...) when the cell is empty. TRichView should correct this bug automatically (using the 0th text style), but it's better to fix it. For example, use InsertRVFFromStream(Stream, 0, Dummy1, Dummy2, False) instead of AppendRVFFromStream.
-1 is not a valid value for ParaNo for the first cell item. So you cannot call Cell.AppendRVFFromStream(...,-1,...) when the cell is empty. TRichView should correct this bug automatically (using the 0th text style), but it's better to fix it. For example, use InsertRVFFromStream(Stream, 0, Dummy1, Dummy2, False) instead of AppendRVFFromStream.
-
- Posts: 148
- Joined: Wed Dec 07, 2005 2:02 pm
- Contact: