Page 1 of 1

Checkpoint navigation

Posted: Fri Dec 23, 2005 1:40 am
by Denis
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 :(

Bookmarks

Posted: Sat Dec 24, 2005 4:06 am
by Denis
Anybody? How to move cursor in table cell[j] ? (or Scroll TRichView)

Posted: Sat Dec 24, 2005 1:29 pm
by Sergey Tkachenko
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+

Posted: Sat Dec 24, 2005 1:32 pm
by Sergey Tkachenko
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.

Scroll

Posted: Thu Jan 26, 2006 9:15 pm
by Denoson
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)?

Posted: Thu Jan 26, 2006 9:20 pm
by Sergey Tkachenko
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)

Thanks

Posted: Thu Jan 26, 2006 10:53 pm
by Denoson
I try to test this code, thanks.

Samples

Posted: Mon Jan 30, 2006 9:54 pm
by Denoson
Ok, this code works Fine!

Re: Checkpoint navigation

Posted: Wed Oct 24, 2018 7:28 pm
by Rael Bauer
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

Re: Checkpoint navigation

Posted: Tue Oct 30, 2018 3:04 pm
by Sergey Tkachenko
In the today's update, GoToCheckpoint procedure from RichViewActions.pas has a new parameter ScrollToCenter: Boolean.