caret at strange position

General TRichView support forum. Please post your questions here
Post Reply
erikvdw
Posts: 40
Joined: Tue Feb 28, 2006 8:27 am

caret at strange position

Post by erikvdw »

I have a form with the richviewedit. Document is loading on an initialize function of the form.
After loading the rvf document the form is shown (by calling showmodal) and the focus is set to the rveditor.
The caret should by show at de first character (or at the end) but It look like the caret is painted at the beginning of the second line.
There is some white space between the caret and first character of the second line.
When using the left key the caret is moved to the second character of the first line. So you should see the caret was before the first character but painted too low and too left.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Can you send me a demo reproducing this problem?
erikvdw
Posts: 40
Joined: Tue Feb 28, 2006 8:27 am

set caret at first position

Post by erikvdw »

What's the way to set the caret at the first position or repaint the editor?

I tried this:

with rvEditor.RVData do
SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0));
rvEditor.TopLevelEditor.Invalidate;
erikvdw
Posts: 40
Joined: Tue Feb 28, 2006 8:27 am

small test

Post by erikvdw »

In a small test program with the same rvf document is seem to be working correct.
So I will search in our program which function cause this problem
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, your code is correct.
The simpler version is

Code: Select all

with rvEditor do begin
  SetSelectionBounds(0, GetOffsBeforeItem(0), 0, GetOffsBeforeItem(0)); 
  Invalidate;
end;
because after such SelectionBounds, rvEditor.TopLevelEditor=rvEditor.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I think this problem is because the editor was not repainted or reformatted after changes.
erikvdw
Posts: 40
Joined: Tue Feb 28, 2006 8:27 am

workaround

Post by erikvdw »

On the onshow event I implemented this code:

cmbFont.SetFocus; //some other component on the same form
Application.ProcessMessages;
rvEditor.SetFocus;
Application.ProcessMessages;

It's a workaround which works. Reformatting or invalidating didn't work.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you have other thirdparty editor controls in your application?

The caret is a global resource. Some another editor can try to control caret even if it is inside TRichViewEdit.
Post Reply