Inserting Text or Items at cursor position

General TRichView support forum. Please post your questions here
Post Reply
semike
Posts: 73
Joined: Wed Sep 07, 2005 6:52 am

Inserting Text or Items at cursor position

Post by semike »

Hello Sergey,

how can I insert a text or an item at a given cursor position (x, y). When I've got a "simple" Text (no tables) my code
> GetItemAt(...)
> SetSelectionBounds(...)
> InsertSomething
works rather fine. But when the existing text contains tables or nested tables my code always adds the text on end of the first item - in most cases before the table.

How do I correctly insert a text on a cursor position? I'll use this code when I drag a VCL component onto the text.

Thank you!
Sergey Tkachenko
Site Admin
Posts: 17312
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

// X, Y - client coordinates

var LRVData: TCustomRVFormattedData;
    LItemNo, LOffs: Integer;
    pt: TPoint;

  pt := rve.ClientToDocument(Point(X,Y));
  if not rve.GetItemAt(pt.X, pt.Y, LRVData, LItemNo, LOffs, True) then
    exit;
  LRVData := TCustomRVFormattedData(LRVData.Edit);
  LRVData.SetSelectionBounds(LItemNo, LOffs, LItemNo, LOffs);
  Insert something
Post Reply