Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 03-27-2015, 12:37 PM   #1
jverrone3
Junior Member
jverrone3 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Mar 2015
Device: none
[Viewer Plugin] Get selected text on right click.

The Calibre ebook viewer has some functionality built into it that I would like to implement with a plugin.

The goal is to have something similar to the "Search Google for [selected text]" when you right click. Instead of the action opening an internet browser, I would like to create a modal pop up that contains more information based on the given text.

Ideally I would also like to create a button in the toolbar that would hold the same functionality.

I see the customize_ui(ui) and customize_context_menu(menu, event, hit_test_result) methods in the ViewerPlugin, but I am stuck on how to actually get the selected text from these parameters and connect a click event to these items.
jverrone3 is offline   Reply With Quote
Old 03-27-2015, 10:57 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
hit_test_result is a QWebHitTestResult. You can use the enclosingFrame().page() method to get a QWebPage and then use selectedText() on the QWebPage.

Alternately, in customize_ui() store a reference to the ui object in your plugin. The do self.ui_ref.document to get a reference to the QWebView.
kovidgoyal is offline   Reply With Quote
Reply

Tags
selected text, viewer context menu, viewer plugin


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to register a plugin to viewer selected text context menu? Gerbrand Development 2 05-04-2014 01:24 PM
[Generate Cover Plugin] I selected a font it didn't like and now it freezes up! eosrose Plugins 1 04-13-2014 07:42 PM
Hyperlink removes selected text DrChiper Editor 28 03-21-2014 12:02 PM
viewer plugin? dhunter Plugins 1 03-08-2012 10:10 PM
Perfect Viewer PDF Plugin GJSmith Kobo Tablets 9 12-01-2011 02:03 PM


All times are GMT -4. The time now is 02:18 AM.


MobileRead.com is a privately owned, operated and funded community.