Page 1 of 1

How can I get the selected text

Posted: Thu Jan 19, 2012 10:28 am
by alexandreq
Hi.

How can I do this?

I want to give a double click on the word, making it selected and on the event of double click I want to get the selected word.

I didn't understand how to do that

thanks

Posted: Thu Jan 19, 2012 5:54 pm
by Sergey Tkachenko
Use RichViewEdit.GetSelText

Posted: Thu Jan 19, 2012 6:43 pm
by alexandreq
Hi,

I use the DBSRichViewEdit1

and I didn't find it with it? Why? Or there is another way to get with DBSRichViewEdit1?

Thanks

Posted: Fri Jan 20, 2012 11:24 am
by alexandreq
Sergey Tkachenko wrote:Use RichViewEdit.GetSelText
Hi,

I use the DBSRichViewEdit1

and I didn't find it with it? Why? Or there is another way to get with DBSRichViewEdit1?

Thanks

Posted: Fri Jan 20, 2012 12:16 pm
by alexandreq
I got the way but I didn't figure out where can I do this:

When I give a double click in a word, it gets selected, after it selected I want to get the text and display it in showmessage.

I put this code on the event doubleclick

ShowMessage( DBSRichViewEdit1.RichViewEdit.GetSelText )

but it is trigger first the word get selected, then, it display an empty value.

How could I work aroung this?

thanks

Posted: Mon Jan 23, 2012 3:01 pm
by Sergey Tkachenko
Unfortunately, OnDblClick is called when the word is not selected yet, so GetSelText returns empty string.
You can use OnRVMouseDown instead:

Code: Select all

procedure TForm3.RichViewEdit1RVMouseDown(Sender: TCustomRichView;
  Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);
begin
  if ssDouble in Shift then
    Caption := RichViewEdit1.GetSelText;
end;

Posted: Mon Jan 23, 2012 5:33 pm
by alexandreq
Hi,

It is not working as it should.

Let me explain why I need this:

I work with a component called chant, this component is a voice syntetizer, when the user click on the word, it wants the word can be read by the syntetizer.

When I click on the word, sometimes the word appear and sometimes doesn't. Another thing that I notice, when I click on the second word, the first one disappear.

did you get it?

Posted: Tue Jan 24, 2012 10:55 am
by Sergey Tkachenko
Sorry, I do not understand.

Do you need to select a word on a single click? You asked about a double click before. Double clicking always selects a clicked word (if you did not exclude rvoDblClickSelectsWord from Options), and OnRVMouseDown with ssDouble in Shift always occurs when the word is selected, so GetSelText returns this word.
If not, please explain how to reproduce this problem, step by step.

What do you mean by appear/disappear?

Posted: Thu Jan 26, 2012 2:08 pm
by mohsen24000
use GetWordAt function

Posted: Thu Jan 26, 2012 2:31 pm
by alexandreq
mohsen24000

Now it worked fine - thanks