|
|
#1 |
|
Junior Member
![]() 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. |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,609
Karma: 28549044
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. |
|
|
|
| Advert | |
|
|
![]() |
| Tags |
| selected text, viewer context menu, viewer plugin |
|
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 02:24 PM |
| [Generate Cover Plugin] I selected a font it didn't like and now it freezes up! | eosrose | Plugins | 1 | 04-13-2014 08:42 PM |
| Hyperlink removes selected text | DrChiper | Editor | 28 | 03-21-2014 01:02 PM |
| viewer plugin? | dhunter | Plugins | 1 | 03-08-2012 11:10 PM |
| Perfect Viewer PDF Plugin | GJSmith | Kobo Tablets | 9 | 12-01-2011 03:03 PM |