How can you tell if a table in a table has the focus?

General TRichView support forum. Please post your questions here
Post Reply
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

How can you tell if a table in a table has the focus?

Post by j&b »

How can you tell if a table in a table has the focus?[/b]
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If rve.TopLevelEditor=rve, the caret is not in table cell.
If rve.TopLevelEditor=rve.InplaceEditor, the caret is inside cell of table that inserted in rve.
Otherwise, the caret is inside a cell of table in table, or table in table in table, and so on.
You can find the level of nesting:

Code: Select all

function GetNestingLevel(rve: TCustomRichViewEdit): Integer;
begin
  Result := 0;
  while rve.InplaceEditor<>nil do begin
    inc(Result);
    rve := TCustomRichViewEdit(rve.InplaceEditor);
  end;
end;
The text and the code above assumes that you are interested in a table having a cell containing the caret. However, GetItemEx method (used in RichViewActions and Editor1 demo to get the table to operate) may return a table having the caret to the right or to the left. For example, if the table A contains the table B, and the caret is to the right of the table B, GetItemEx returns table B, not table A, despite the fact that the caret is in the cell of table A. If you are in this kind of focus, you can compare the editor returned by GetItemEx (the editor containing the table) with rve, rve.InplaceEditor, and so on.
Post Reply