OnRVMouseDown and get ItemNo

General TRichView support forum. Please post your questions here
Post Reply
frost
Posts: 1
Joined: Wed Mar 29, 2006 9:35 am

OnRVMouseDown and get ItemNo

Post by frost »

Hello!
Please help me.
I want to get Tag number in OnRVMouseDown event and I can not....
OnRVMouseDown returns ItemNo, but my ItemTag are in the table.... and I receive ItemNo table (not my ItemTag) please see example:

1. Create table and insert ItemTag in table:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
  var
     table : TRVTableItemInfo;
begin
  RichView1.Clear;
  
  table := TRVTableItemInfo.CreateEx(1{Rows}, 2{Cols}, RichView1.RVData);
  table.Cells[0,0].Clear;
  table.Cells[0,0].AddNLTag('Item Tag ¹1', 1, 0, integer(StrNew('123')));  

  table.Cells[0,1].Clear;
  table.Cells[0,1].AddNLTag('Item Tag ¹2', 1, 0, integer(StrNew('456')));

  RichView1.AddItem('', table);
  RichView1.Format;
end;
2. OnRVMouseDown.....

Code: Select all

procedure TForm1.RichView1RVMouseDown(Sender: TCustomRichView;
  Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);
begin
  //I mouse down on my ItemTag "'Item Tag 2" but ItemNo is TABLE No........
  Panel1.Caption := IntToStr(ItemNo);
end;
--
How i can get ItemNo of Item Tag 1 or 2 (its in table) and how i can get tag number of this item
Thanks!
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

Try

Code: Select all

procedure TForm1.RichView1RVMouseDown(Sender: TCustomRichView;
  Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);
var 
  TrueItem :  integer;
begin
  if ItemNo = -60 then begin
    TrueItem := RichView1.TopLevelEditor.RVData.GetItemNo;
    //This way you get the item no of the item within the tabel
end;
or the GetItemNo should be CurItemNo

Good luck.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

procedure TForm1.MyRichViewMouseDown(Sender: TCustomRichView;
  Button: TMouseButton; Shift: TShiftState;
  ItemNo, X, Y: Integer);
var LRVData: TCustomRVFormattedData;
    LItemNo, LOffs: Integer;
    pt: TPoint;
begin
  pt := MyRichView.ClientToDocument(Point(X,Y));
  if MyRichView.GetItemAt(pt.X, pt.Y, LRVData, LItemNo, LOffs, True) then
    if rvoTagsArePChars in MyRichView.Options then
      Panel.Caption := PChar(LRVData.GetItemTag(LItemNo))
    else
      Panel.Caption := IntToStr(LRVData.GetItemTag(LItemNo));
end;
shmp
Posts: 140
Joined: Sun Aug 28, 2005 10:19 am
Location: Sabah, Malaysia.
Contact:

Post by shmp »

Oops! TopLevelEditor does not work for RichView. Sorry for the mess.
Post Reply