TMSFMXWebBrowser gesture and selection


1. how can i handdle web browser gestures?
2. how can i get selected text from web browser ?
3. how can i change text selection menu?
thank you


Please can you specify exactly which platform you are using?

Kind Regards, 
delphi xe7

Which target platform are you using (Win32, OSX32, iOSDevice, ....) ?

ios device and android

We have investigated this here. 

1) Gestures are currently not supported. But we have added this on our feature request list for investigation.
2) For iOS you can get the selected text through javascript:

  s: String;
  s := TMSFMXWebBrowser1.ExecuteJavascript('window.getSelection().toString();');

For Android, the selection cannot be retrieved using javascript because the native webbrowser doesn't expose functionality for this. We have added this on our feature request list for further investigation. 

3) Customizing the context menu requires a significant amount of javascript injection. There is also no support for this as this is a very specific request.

i think i can write this code to event in delphi when a text select in webbrowser. 
  s := TMSFMXWebBrowser1.ExecuteJavascript('window.getSelection().toString();');

what is your advice about , which event in delphi?

There is no separate event when the selection changes. the TTMSFMXWebBrowser is a wrapper around the native webbrowser that exposes basic functionality such as executing javascript, loading and navigating to an URL, going to the previous and next page. There is currently no support for such specific functionality.

Kind Regards, 

can i adapt with JNI or native code for that events?

i need your advice.

i have to develop a book reader software.
i have books and book pages has simple  html tags, like <b>test1 test2</b><p>test 3 test 4 <br> test5...

1. user can add notes to any words by selecting. This notes must save to sql lite.
2. when open the app again, app must start where user left last time.

working solution:
a. i used TTMSFMXWebBrowser component
b. every page code i added a javascript, "on select" event  open a window for note.
c. for old notes i added the every note word, <a id="note-<note database id>" href="<note database id>">

  when select text on web page, i send a url change event to delphi. 
at delphi i used BeforeNavigate event.

if params.url has;

if it is a new note url like this
if user want to edit note, url like<note database id>

it is the summary.

what components or technics you adviced to me for better coding and performance?
thank you  


If you have an online reader the best approach is what you are currently using (with the TTMSFMXWebBrowser). For the selection change event, you can use the OnBeforeNavigate event and the OnNavigateComplete events and redirect the browser to an URL when selection changes. (set the Window href URL to an url scheme such as "selectionevent://..." then you can parse the URL and return a false to block navigation and stay on the current page. The selection changed event cannot be separately handled inside the TTMSFMXWebBrowser.

Kind Regards,