[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: 13149
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[Demo] Editing a list of foonotes/endnotes

Post by Sergey Tkachenko » Thu Mar 13, 2014 9:19 am

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.

tothpaul
Posts: 14
Joined: Fri Feb 06, 2015 10:41 am

Post by tothpaul » Fri Feb 06, 2015 10:48 am

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: 13149
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Tue Feb 17, 2015 5:44 pm

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: 13149
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Wed Mar 11, 2015 8:21 am

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: 13149
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Thu May 21, 2015 6:13 pm


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest