I have a Ribbon Context Tab for Table, whenever caret is in table, the Table Tab will be visible.
I try these to check if caret in a table
1. Result := (rve.InplaceEditor <> nil);
2. Result := rve.GetCurrentItemEx(TRVTableItemInfo, rve, ItemInfo);
3.
begin
Result := rve.GetCurrentItemEx(TRVTableItemInfo, rve, ItemInfo);
if Result then
begin
table := TRVTableItemInfo(ItemInfo);
Result := table.GetNormalizedSelectionBounds(True, R, c, cs, rs);
end;
end;
But all of them cannot meet my requirement. When caret in one of the cell, the above solutions is working, but when multiple cells are selected, i will get false.
Table Context
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 16
- Joined: Mon May 09, 2016 9:16 am
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
If you use RichViewActions for table operations, I suggest to consider showing the tab when the caret is to the left/right of the table, to make your application consistent.
Because, all RichViewActions working with tables (if they do not require selected cells), are applied to the table when the caret is to the left/right of it.
It is especially important for nested tables: when the caret is to the left/right of the nested table, actions are applied to the nested table, not to the parent table.
But of course, if you implement table operations yourself, you can implement your own logic.
Your code in (3) is almost ok.
It must return True if there is a table having a multicell selection or an edited cell.
It has only one problem: it's possible, that table is nested in a cell of a parent table. In this case, the tab should be displayed, and operations must be performed on the parent table.
(if the editor contained the table (rve2) is not equal to the root editor (rve), this is an inplace editor of a parent table; this table can be get as
(rve2.RVData.GetSourceRVData as TRVTableCellData).GetTable)
Because, all RichViewActions working with tables (if they do not require selected cells), are applied to the table when the caret is to the left/right of it.
It is especially important for nested tables: when the caret is to the left/right of the nested table, actions are applied to the nested table, not to the parent table.
But of course, if you implement table operations yourself, you can implement your own logic.
Your code in (3) is almost ok.
It must return True if there is a table having a multicell selection or an edited cell.
It has only one problem: it's possible, that table is nested in a cell of a parent table. In this case, the tab should be displayed, and operations must be performed on the parent table.
Code: Select all
Result := rve.GetCurrentItemEx(TRVTableItemInfo, [color=red]rve2[/color], ItemInfo);
if Result then
begin
table := TRVTableItemInfo(ItemInfo);
Result := table.GetNormalizedSelectionBounds(True, R, c, cs, rs);
[color=red] if not Result then
Result := rve2 <> rve;[/color]
end;
(rve2.RVData.GetSourceRVData as TRVTableCellData).GetTable)
-
- Posts: 16
- Joined: Mon May 09, 2016 9:16 am
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: