Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

place the selected text on the page into a variable

Post Reply
dvbss11
Posts: 28
Joined: Sat Oct 26, 2019 6:30 pm

place the selected text on the page into a variable

Post by dvbss11 »

how to put in a variable the selected text on the page?

Code: Select all

TOnTextSelectionChanged         = procedure(Sender: TObject; const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange) of Object;
which event will connect to?
dvbss11
Posts: 28
Joined: Sat Oct 26, 2019 6:30 pm

Re: place the selected text on the page into a variable

Post by dvbss11 »

Code: Select all

procedure TBrauserChrom.Chrom_TextSelectionChanged(Sender: TObject; const browser: ICefBrowser; const selected_text: ustring; const selected_range: PCefRange);
begin
   FHelpTextSelection:= selected_text;
   showmessage(FHelpTextSelection);
end;
did not work like that
User avatar
salvadordf
Posts: 4042
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: place the selected text on the page into a variable

Post by salvadordf »

Hi,

The TChromium.OnTextSelectionChanged event is only available in OSR mode. Browsers in "normal" mode will not get that event.

You also have to consider that all TChromium events are executed in a CEF thread. This means that you have to protect the variables with synchronization objects like critical sections

Remember that VCL is not thread safe and your application shouldn't create, destroy or modify any VCL control inside TChromium's events.
dvbss11
Posts: 28
Joined: Sat Oct 26, 2019 6:30 pm

Re: place the selected text on the page into a variable

Post by dvbss11 »

https://prnt.sc/ul6uge

in the mini browser there is a copy when selected I do not have it
what does OSR mean?
User avatar
salvadordf
Posts: 4042
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: place the selected text on the page into a variable

Post by salvadordf »

dvbss11 wrote: Mon Sep 21, 2020 2:37 pm https://prnt.sc/ul6uge
in the mini browser there is a copy when selected I do not have it
That menu option is added automatically by Chromium when the user can copy something from the document.
dvbss11 wrote: Mon Sep 21, 2020 2:37 pm what does OSR mean?
It's the "off-screen rendering" mode used by the SimpleOSRBrowser demo. It gives you total control of the browser events and it uses the TChromium.OnPaint event to send raw bitmap data with the web contents. It's much slower but you have total control.
Post Reply