Checkpoint navigation

General TRichView support forum. Please post your questions here
Post Reply
Denis

Checkpoint navigation

Post by Denis » Fri Dec 23, 2005 1:40 am

Can you send example of code:
How to move cursor to checkpoint, if this checkpoint inside table cell?
.............
I run recurce scanner for cells bookmarks (your example Demos/Autoscan URL). And scan all bookmarks.

But I can not put cursor on cells bookmarks :(

Denis

Bookmarks

Post by Denis » Sat Dec 24, 2005 4:06 am

Anybody? How to move cursor in table cell[j] ? (or Scroll TRichView)

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

Post by Sergey Tkachenko » Sat Dec 24, 2005 1:29 pm

I have examples for Delphi:

Example 1:

Code: Select all

function ScrollToCheckpoint(rv: TCustomRichView; const CPName: String): Boolean;

function _ScrollToCheckpoint(RVData: TCustomRVFormattedData;
  rv: TCustomRichView; const CPName: String): Boolean;
var i,r,c,x,y: Integer;
    Tag: TRVTag;
    CPD: TCheckpointData;
    Name: String;
    RI: Boolean;
    table: TRVTableItemInfo;
begin
  for i := 0 to RVData.ItemCount-1 do begin
    CPD := RVData.GetItemCheckpoint(i);
    if Assigned(CPD) then begin
      RVData.GetCheckpointInfo(CPD, Tag, Name, RI);
      if Name=CPName then begin
        RVData.GetOriginEx(x,y);
        rv.ScrollTo(y+RVData.GetCheckpointYEx(CPD));
        Result := True;
        exit;
      end;
    end;
    if RVData.GetItemStyle(i)=rvsTable then begin
      table := TRVTableItemInfo(RVData.GetItem(i));
      for r := 0 to table.Rows.Count-1 do
        for c := 0 to table.Rows[r].Count-1 do
          if table.Cells[r,c]<>nil then begin
            Result := _ScrollToCheckpoint(
              TCustomRVFormattedData(table.Cells[r,c].GetRVData),
              rv, CPName);
            if Result then
              exit;
          end;
    end;
  end;
  Result := False;
end;

begin
  Result := _ScrollToCheckpoint(rv.RVData, rv, CPName);
end;
Example 2:

Code: Select all

function GoToCheckpoint(rv: TCustomRichViewEdit; const CPName: String): Boolean;

function _GoToCheckpoint(RVData: TCustomRVFormattedData;
  rv: TCustomRichViewEdit; const CPName: String): Boolean;
var i,r,c,x,y: Integer;
    Tag: TRVTag;
    CPD: TCheckpointData;
    Name: String;
    RI: Boolean;
    table: TRVTableItemInfo;
begin
  for i := 0 to RVData.ItemCount-1 do begin
    CPD := RVData.GetItemCheckpoint(i);
    if Assigned(CPD) then begin
      RVData.GetCheckpointInfo(CPD, Tag, Name, RI);
      if Name=CPName then begin
        RVData := TCustomRVFormattedData(RVData.Edit);
        RVData.SetSelectionBounds(i, RVData.GetOffsBeforeItem(i), i, RVData.GetOffsBeforeItem(i));
        Result := True;
        exit;
      end;
    end;
    if RVData.GetItemStyle(i)=rvsTable then begin
      table := TRVTableItemInfo(RVData.GetItem(i));
      for r := 0 to table.Rows.Count-1 do
        for c := 0 to table.Rows[r].Count-1 do
          if table.Cells[r,c]<>nil then begin
            Result := _GoToCheckpoint(
              TCustomRVFormattedData(table.Cells[r,c].GetRVData),
              rv, CPName);
            if Result then
              exit;
          end;
    end;
  end;
  Result := False;
end;

begin
  Result := _GoToCheckpoint(rv.RVData, rv, CPName);
end;
Update 2012-02-28: modified for compatibility with TRichView 13.4+
Last edited by Sergey Tkachenko on Tue Feb 28, 2012 12:28 pm, edited 2 times in total.

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

Post by Sergey Tkachenko » Sat Dec 24, 2005 1:32 pm

As you can see, for moving caret to the cell, you need to call Cell.Edit(). This method returns RVData of the cell inplace editor (also available as Cell.GetRVData()). Using this RVData, you can move caret to the specifying item with the method SetSelectionBounds.

Denoson
Posts: 71
Joined: Tue Jan 24, 2006 9:25 pm
Contact:

Scroll

Post by Denoson » Thu Jan 26, 2006 9:15 pm

Sergey, thank you for this example. This code works fine for TRichViewEdit :lol: , but TRichView can't scroll on Cell.Edit() :(

Can you help for Viewer (scroll to table cell / bookmark)?

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

Post by Sergey Tkachenko » Thu Jan 26, 2006 9:20 pm

The Example 1 is for TRichView and TRichViewEdit (scrolling to the checkpoint), The Example 2 is for TRichViewEdit only (I fixed the rv parameter type)

Denoson
Posts: 71
Joined: Tue Jan 24, 2006 9:25 pm
Contact:

Thanks

Post by Denoson » Thu Jan 26, 2006 10:53 pm

I try to test this code, thanks.

Denoson
Posts: 71
Joined: Tue Jan 24, 2006 9:25 pm
Contact:

Samples

Post by Denoson » Mon Jan 30, 2006 9:54 pm

Ok, this code works Fine!

Rael Bauer
Posts: 34
Joined: Tue Aug 21, 2007 4:47 am

Re: Checkpoint navigation

Post by Rael Bauer » Wed Oct 24, 2018 7:28 pm

Hi,

The above ScrollToCheckpoint routine will bring the checkpoint into view, sometimes at the bottom of the visible area. How can I make ScrollToCheckpoint bring the checkpoint to the middle of the visible area?

Thanks
Rael

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

Re: Checkpoint navigation

Post by Sergey Tkachenko » Tue Oct 30, 2018 3:04 pm

In the today's update, GoToCheckpoint procedure from RichViewActions.pas has a new parameter ScrollToCenter: Boolean.

Post Reply