TCustomRichView.OnRVMouseDown

<< Click to display table of contents >>

TCustomRichView.OnRVMouseDown

Occurs when the user presses a mouse button with the mouse pointer over the control.

type

  TRVMouseEvent =

    procedure(Sender: TCustomRichView; Button: TMouseButton;

    Shift: TShiftState; ItemNo, X, Y: TRVCoordof object;

 

property OnRVMouseUp: TRVMouseEvent;

Similar to OnMouseDown, but you also have information about index of item under the mouse pointer.

ItemNo is an index of this item, or -1 if there is no item at the position of the mouse pointer.

The OnRVMouseDown event handler can respond to left, right, or center mouse button presses and shift key plus mouse-button combinations. Shift keys are the  Shift ,  Ctrl , and  Alt  keys. X and Y are the pixel coordinates of the mouse pointer in the client area of the Sender.

 

When clicking on table, this event returns ItemNo of this table in the root document, even if user clicked on item inside this table.

Use the following procedure if you want to know the exact clicked item:

procedure TForm1.MyRichViewRVMouseDown(Sender: TCustomRichView;

  Button: TMouseButton; Shift: TShiftState;

  ItemNo, X, Y: TRVCoord);

var LRVData: TCustomRVFormattedData;

    LItemNo, LOffs: Integer;

    pt: TRVCoordPoint;

begin

  pt := MyRichView.ClientToDocument(Point(X,Y));

  if not MyRichView.GetItemAt(pt.X, pt.Y, LRVData, LItemNo, LOffs,

    True) then

    exit;

  // item is the LItemNo-th item in LRVData

  // example of using: LRVData.GetItemStyle (LItemNo)

  ..

end;

Note: if you want to create code responding on clicking on item, it's recommended to use OnRVMouseUp instead of OnRVMouseDown.

 

See also events:

OnRVMouseUp.