Page 1 of 1

OnRVMouseDown and get ItemNo

Posted: Wed Mar 29, 2006 9:40 am
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!

Posted: Wed Mar 29, 2006 12:30 pm
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.

Posted: Wed Mar 29, 2006 2:26 pm
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;

Posted: Thu Mar 30, 2006 12:25 pm
by shmp
Oops! TopLevelEditor does not work for RichView. Sorry for the mess.