How can I get the selected text

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

How can I get the selected text

Post 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
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Use RichViewEdit.GetSelText
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post 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
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post 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
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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?
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

Post by mohsen24000 »

use GetWordAt function
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

mohsen24000

Now it worked fine - thanks
Post Reply