How to prevent a table cell to get focus?

General TRichView support forum. Please post your questions here
Post Reply
dudubaiao
Posts: 5
Joined: Thu Apr 20, 2006 5:34 pm

How to prevent a table cell to get focus?

Post by dudubaiao »

Hi,

I'm filling some cells of a table with text and other cells with TEdits.
I just want to avoid that the user sets the focus on the text cells.

Search on RVItem unit I found this:

TRVItemBoolPropertyEx = (rvbpPrintToBMP, rvbpJump,
rvbpAllowsFocus,rvbpHotColdJump,
rvbpXORFocus, rvbpHotCold, rvbpActualPrintSize)

But I could not know if I can use this with table cells.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This property has different meaning (this "focus" is a dotted rectangle that TRichView (not TRichViewEdit) can draw around some items, such as hyperlinks).

You can use table.OnCellEditing event to move caret to another cell.
For example, this code does not allow to put caret in cells of the first column:

Code: Select all

procedure TForm3.CellEditing(Sender: TRVTableItemInfo; Row, Col: Integer;
  Automatic: Boolean; var AllowEdit: Boolean);
begin
  AllowEdit := Col>0;
end;
Table events are not saved in RVF files (and are lost on copy-pasting). To prevent this problem, this event should be assigned in OnItemAction event:

Code: Select all

procedure TForm3.RichViewEdit1ItemAction(Sender: TCustomRichView;
  ItemAction: TRVItemAction; Item: TCustomRVItemInfo; var Text: String;
  RVData: TCustomRVData);
begin
  if (ItemAction=rviaInserting) and (Item.StyleNo=rvsTable) then
    TRVTableItemInfo(Item).OnCellEditing := CellEditing;
end;
Post Reply