readium / SDKLauncher-iOS

A small iOS application to serve as a launcher/testbed for the Readium SDK.
BSD 3-Clause "New" or "Revised" License
71 stars 47 forks source link

In iOS How to get the click on the location of the information and get the selected text string? #92

Open dengzhucai opened 7 years ago

dengzhucai commented 7 years ago

Hi @danielweck , I want to click on the location of the information and the content of the selected text, such as:[NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", touch.x, touch.y]; window.getSelection().getRangeAt(0).toString() ;

I have a getElementFromPoint method found in the file(readium-shared-js.js) But I don't know how to use. Thanks and waiting on your response.

danielweck commented 7 years ago

Using Javascript code, you could implement a small routine that creates a text range selection in the DOM based on the location of the user's click / touch. Then, you could exploit the DOM selection created by the webview, simply by using the existing "highlights" plugin: https://github.com/readium/readium-shared-js/tree/develop/plugins/highlights