How to get the word when the mouse is over it?

General TRichView support forum. Please post your questions here
Post Reply
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

How to get the word when the mouse is over it?

Post by alexandreq »

Hello Sergey,

I have a text and a table with words and theis meanings.

When the mouse is over a word of my text, I need to get the word so that I can find it in my dictionary and display its mean in a hint.

Well, to do this, I just need to get the word where is my mouse over.

How can I do this onItemHint?


thanks
Alexandre
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Sergey, I tried to get, but I can't get only the word, it returns me more than 1 word.

I also tried to use your example:

if RVData.GetItem(ItemNo) is TCustomRVNoteItemInfo then
HintText := GetRVDataText(TCustomRVNoteItemInfo(RVData.GetItem(ItemNo)).Document)
else
HintText := GetRVDataText(RVData)

Even using this:

HintText := RVData.GetItemText(ItemNo)

I really don't know what to do, how to return only the word. :(
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Use TSRichViewEdit.OnMouseMove event.
The example above displays words below the mouse in the form's Caption:

Code: Select all

uses CRVFData; 
procedure TForm3.SRichViewEdit1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var pt: TPoint;
  RVData: TCustomRVFormattedData;
  InPageArea, InLeftArea, InTextArea: Boolean;
  ItemNo: Integer;
  Wrd: String;
begin
  pt := SRichViewEdit1.ConvertSRVtoRV(Point(X, Y), InTextArea, InLeftArea, InPageArea);
  if InTextArea then begin
    SRichViewEdit1.ActiveEditor.GetWordAt(pt.X, pt.Y, RVData, ItemNo, Wrd);
    if (ItemNo>=0) and (RVData.GetItemStyle(ItemNo)>=0) then
      Caption := Wrd
    else // in page, but not over a word
      Caption := '';
    end
  else // not in page
    Caption := '';
end;
Post Reply