[Demo] Editing a list of foonotes/endnotes

Demos, code samples. Only questions related to the existing topics are allowed here.
Post Reply
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[Demo] Editing a list of foonotes/endnotes

Post by Sergey Tkachenko »

http://www.trichview.com/support/files/listofnotes.zip

This is a modification of Demos\Delphi\Editors\Notes\ demo

Two new commands are added in the Notes menu:
- Edit List of Foonotes...
- Edit List of Endnotes...

These commands open a dialog window where you can edit all notes in a table.

Image

This example assumes that StyleTemplates are not used. We can create a demo with StyleTemplates on request.

Updates:
2018-Apr-18: for compatibility with TRichView 17
tothpaul
Posts: 42
Joined: Fri Feb 06, 2015 10:41 am

Post by tothpaul »

nice demo that is almost what I need, but is there any way to avoid the cursor to go outside the table ?

let's add some notes, go to the editor, click on a note and start selecting text with Shift+RightArrow; when you reach the end of line the cursor leaves the cell and go to the right of the table :/
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry for the delay.
In this demo, you can place the caret before or after the table, but it does not allow typing there (because the table is inserted in a read-only paragraph).

If you do not like it, you can process OnCaretMove, and when the caret is outside the table, move it back. I'll make an example later in this week.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

How to prevent the caret moving outside the table of notes.

Open NoteListFrm.pas.

1) Add in the interface section, in "uses": CRVData;

2)Add in the interface section:

Code: Select all

const WM_BACKTOTABLE = WM_USER+1;
2) Add in the declaration of TfrmNoteList:

Code: Select all

    Cell: TRVTableCellData;
    ItemNo, Offs: Integer;
    Moving: Boolean;
    procedure WMBackToTable(var Msg: TMessage); message WM_BACKTOTABLE;
4) Add rveCaretMove handling rve.OnCaretMove.

3) Add in the implementation:

Code: Select all

procedure TfrmNoteList.rveCaretMove(Sender: TObject);
begin
  if not Visible or Moving then
    exit;
  if (rve.InplaceEditor=nil) and not (rvstCreatingInplace in rve.RVData.State) then begin
    PostMessage(Handle, WM_BACKTOTABLE, 0, 0);
    exit;
  end;
  if rve.InplaceEditor=nil then
    exit;
  Cell := rve.TopLevelEditor.RVData.GetSourceRVData as TRVTableCellData;
  ItemNo := rve.TopLevelEditor.CurItemNo;
  Offs := rve.TopLevelEditor.OffsetInCurItem;
end;

procedure TfrmNoteList.WMBackToTable(var Msg: TMessage);
var RVData: TCustomRVFormattedData;
begin
  if not Visible or (rve.InplaceEditor<>nil) or (Cell=nil) then
    exit;
  Moving := True;
  try
    rve.RVData.State := rve.RVData.State - [rvstMakingSelection, rvstLineSelection];
    RVData := Cell.Edit as TCustomRVFormattedData;
    RVData.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);
  finally
    Moving := False;
  end;
end;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Post Reply