Scroll Past End of Doc

General TRichView support forum. Please post your questions here
Post Reply
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Scroll Past End of Doc

Post by standay »

Hi Sergey,

Is there a way to scroll an rve past the end line? I tried rvoScrollToEnd but I don't see it doing anything.

In my scintilla control, I can set it to scroll to the end of the text:

scroll to end.png
scroll to end.png (33.7 KiB) Viewed 10559 times
Or, scroll past the end:

scroll past end.png
scroll past end.png (15.14 KiB) Viewed 10559 times
I'd like to get the rve to scroll past the end if possible.

Thanks Sergey
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Scroll Past End of Doc

Post by Sergey Tkachenko »

If you simply want to scroll, you can call

Code: Select all

rv.VScrollPos := rv.VScrollMax
or

Code: Select all

rv.ScrollTo(rv.DocumentHeight)
(in FMX version, ScrollTo is renamed to ScrollToPosition).

If you want to move the caret to the end of the document, you can do it

Code: Select all

var
  ItemNo, Offs: Integer;
ItemNo := rve.ItemCount - 1;
Offs := rve.GetOffsAfterItem(ItemNo);
rve.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);
or

Code: Select all

rve.MoveCaret(rvcmBottom);
PS: rvoScrollToEnd is used by rv.FormatTail; it may be useful to implement chats.
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Scroll Past End of Doc

Post by standay »

I was actually wanting to scroll past the end of the doc, beyond the last line of actual text. But I doubt the rve does that. Not a big deal, be nice if it did but no problem.

The scroll code was helpful, thanks. I was just about to try and figure out how to scroll to the end of the doc today so that saved me some time.

Stan
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Scroll Past End of Doc

Post by standay »

Hi Sergey,

I was playing around with this today and I got the rve to do just what I wanted. I put a copy of RVScroll.pas into my app's folder, then, in that copy, I changed line 817:

Code: Select all

      FVScrollMax := YSize - 1;
to:

Code: Select all

      if FVscrollVisible then
        FVScrollMax := YSize - 1 + (FVScrollPage-4);
This gives me the effect I want. LibreOffice and Word do the same thing in a way. When you are in "normal" view mode, you can scroll the whole page up and down regardless of how much text is on it.

My guess is the Scale rve does that too, but I have not used that one yet. What I did above is for a plain rve.

Could you try it and take a look at it and see what you think? I think you'll see right away what I'm after. What I have works fine, but I have no idea of the interaction with other parts of the component which was why I was hoping you could look at it.

I would say if it looked like something you could implement, that you could add an option to TCustomRichView.Options

Code: Select all

     rvoScrollPastEnd,           // if set, vertical scrolling will scroll beyond the end of text
Thanks Sergey. No hurry on this.

Stan
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Scroll Past End of Doc

Post by Sergey Tkachenko »

I think it's better to implement this effect by increasing value of BottomMargin property.
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Scroll Past End of Doc

Post by standay »

Sergey Tkachenko wrote: Sat Sep 18, 2021 6:30 pm I think it's better to implement this effect by increasing value of BottomMargin property.
This is why I ask about these things! Yes, that's a much simpler way and seems to work the same. BTW, I like being able to scroll past the end (or scroll the bottom up or however you want to think of it) as it makes it easier to edit text at the bottom of the document since you can scroll it up into view to work on.

Thanks Sergey. Great idea. I would never have thought to use the bottom margin.

Stan
Post Reply