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!
Inserting Text or Items at cursor position
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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