Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get the selected text from iframe #45

Closed
sureshmuttagi opened this issue Apr 7, 2014 · 4 comments

Comments

@sureshmuttagi
Copy link

commented Apr 7, 2014

Hi,
I need to get selected text from iframe. But i tried most of the codes n tricks, i failed to catch the mouse events on iframe. Please let me know what changes i supposed to do...Thanks in advance

@jccr

This comment has been minimized.

Copy link
Member

commented Apr 8, 2014

There is an event emitted from a Readium Reader instance called "textSelectionEvent". This will tell you when a user has finished selecting something inside an iframe. As of this moment it is implemented at a basic level in the "develop" branch in the epub annotations module: https://github.com/readium/readium-shared-js/blob/develop/lib/annotations_module.js

Search for "// emit an event when user selects some text." in that file to see how this event is implemented.

@sureshmuttagi

This comment has been minimized.

Copy link
Author

commented Apr 9, 2014

Hi ,

Thanks a lot for the clue. I am using readium-js-viewer in visual studio
2012 to read epub files.Can you please tell me how can I use this
annotations_module.jshttps://github.com/readium/readium-shared-js/blob/develop/lib/annotations_module.js
in
my project.

On Wed, Apr 9, 2014 at 2:50 AM, Juan Corona notifications@github.comwrote:

There is an event emitted from a Readium Reader instance called
"textSelectionEvent". This will tell you when a user has finished selecting
something inside an iframe. As of this moment it is implemented at a basic
level in the "develop" branch in the epub annotations module:
https://github.com/readium/readium-shared-js/blob/develop/lib/annotations_module.js

Search for "// emit an event when user selects some text." in that file to
see how this event is implemented.

Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-39903357
.

Regards,
Suresh S. Muttagi
Software Developer,
Bangalore.
+91-9986461877

@jccr

This comment has been minimized.

Copy link
Member

commented Apr 9, 2014

Are you embedding the readium-js-viewer in a web component/view for a non javascript project in visual studio 2012? Do you have somewhere to run Javascript code on the readium-js-viewer's Readium instance? Readium is initialized by the viewer here: https://github.com/readium/readium-js-viewer/blob/develop/lib/EpubReader.js#L542

You have to expose that reference and then you can add an event handler (that event is emitted by the annotations_module, you don't have to worry about using it directly).

For example (javascript):
readium.reader.on('textSelectionEvent', function(e) { var theSelectedText = e.view.getSelection().toString(); alert(theSelectedText); });

You can even stick this code here: https://github.com/readium/readium-js-viewer/blob/develop/lib/EpubReader.js#L554
and see if it works for you.

@danielweck danielweck added the question label Jul 7, 2014
@danielweck

This comment has been minimized.

Copy link
Contributor

commented Jul 7, 2014

Closing this "non-issue".

@danielweck danielweck closed this Jul 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.