Page 1 of 1

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

Posted: Wed Apr 11, 2012 3:27 pm
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

Posted: Fri Apr 13, 2012 8:44 pm
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. :(

Posted: Sun Apr 15, 2012 6:51 am
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;